using DAO;
using GetOffice;
using JRO;
using Microsoft.VisualBasic;
using Microsoft.Win32;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Data.OleDb;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.Drawing.Text;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text;
using System.Windows.Forms;
using System.Xml;
namespace Easislides
{
	internal class gf
	{
		public enum SettingsCategory
		{
			RotateString = 10
		}
		public enum InterFormMessageType
		{
			MessageAlert,
			ParentalAlert,
			LyricsAlert,
			MediaItemIsVideo,
			MediaItemIsNotVideo,
			MediaItemPlaying,
			MediaItemStopped,
			SongChanged,
			MovedToGapItem,
			SlideChanged,
			EndShow,
			MouseDownLeft,
			MouseDownRight,
			MouseUp
		}
		public enum MediaInputDevice
		{
			File,
			Capture
		}
		public enum MediaBackgroundStyle
		{
			None,
			Audio,
			Video,
			SameAsPrevious
		}
		public enum PlayState
		{
			Stopped,
			Paused,
			Running,
			Init
		}
		public enum FormatCategory
		{
			SystemID = 1,
			PanelBackColour = 11,
			PanelBackColourTransparent,
			PanelTextColour,
			PanelTextColourAsRegion1,
			PanelShowDataDisplay,
			PanelBottomBorderFactor,
			PanelFontName,
			PanelFontStyle,
			PanelIndicatorsFontSize,
			ShowHeadingsStyle = 21,
			ShowSongSetings,
			ShowHeadingsAlign,
			ShowLyrics = 25,
			ShowScreenColour1,
			ShowScreenColour2,
			ShowScreenStyle,
			ShowFontColour1,
			ShowFontColour2,
			ShowFontAlign1,
			ShowFontAlign2,
			ShowFontStyle1 = 41,
			ShowFontStyle2,
			ShowFontName1,
			ShowFontName2,
			ShowFontVPosition1,
			ShowFontVPosition2,
			ShowFontSize1,
			ShowFontSize2,
			ShowMediaOption = 50,
			ShowMediaLocation,
			ShowMediaVolume,
			ShowMediaBalance,
			ShowMediaOnOffSettings,
			ShowMediaCaptureDeviceNumber,
			ShowBackgroundPicture = 61,
			ShowBackgroundMode,
			ShowVerticalAlign,
			ShowLeftMargin,
			ShowRightMargin,
			ShowBottomMargin,
			ShowTransposeOffset = 71,
			ShowItemTransition,
			ShowSlideTransition,
			PBFontStyleNumber = 101,
			PBHeadingNumber,
			PBFontColourNumber,
			PBFontStyleTitle = 106,
			PBHeadingTitle,
			PBFontColourTitle,
			PBFontStyleCopyright = 111,
			PBHeadingCopyright,
			PBFontColourCopyright,
			PBFontStyleVerse = 116,
			PBHeadingVerse,
			PBFontColourVerse,
			PBFontStyleChorus = 121,
			PBHeadingChorus,
			PBFontColourChorus,
			PBFontStyleNotations = 126,
			PBHeadingNotations,
			PBFontColourNotations,
			PBFontStyleBook = 131,
			PBHeadingBook,
			PBFontColourBook,
			PBFontStyleUser = 136,
			PBHeadingUser,
			PBFontColourUser,
			PBShowHeadings1 = 151,
			PBLyricsPattern = 153,
			PBShowSection,
			PBShowColumns,
			PBPageSize,
			PBSpacing1 = 170,
			PBSpacing2,
			PBShowScreenBreaks,
			PBOneSongPerPage,
			PBCJKGroupStyle,
			PBShowSettings = 180
		}
		public enum PraiseBookSections
		{
			Number,
			Title,
			Copyright,
			Verse,
			Chorus,
			Notations,
			BookRef,
			UserRef
		}
		public enum ShowHeadingsStyle
		{
			None,
			All,
			AtStartOnly
		}
		public enum DatabaseType
		{
			Songs,
			Usages,
			Bible
		}
		public enum VAlign
		{
			Top,
			Centre,
			Bottom
		}
		public enum ImageMode
		{
			Tile,
			Centre,
			BestFit
		}
		public enum HAlign
		{
			Left = 1,
			Centre,
			Right
		}
		public enum PanelRef
		{
			None,
			Book,
			User
		}
		public enum DisplayRegions
		{
			Heading,
			Region1,
			Region2,
			BothRegions
		}
		public enum UsageMode
		{
			Worship,
			Collection,
			PraiseBook
		}
		public enum FileContentsType
		{
			DoubleByte,
			Ascii_Rtf,
			Ascii_Html
		}
		public enum PraiseBookLayout
		{
			WorshipList,
			PraiseBook
		}
		public enum GapMedia
		{
			None,
			SameAsPrevious,
			SessionMedia
		}
		public enum FontEffect
		{
			Normal,
			Shadow,
			Outline,
			OutlineAndShadow = 2
		}
		public enum HeadingFormat
		{
			AsRegion1,
			AsRegion1Plus,
			Individual
		}
		public enum GapType
		{
			None,
			Black,
			Default,
			User
		}
		public enum AlertType
		{
			Parental,
			Message
		}
		public enum ThumbImagesType
		{
			Backgrounds,
			PreviewPP,
			OutputPP
		}
		public enum SortBy
		{
			Alpha,
			WordCount,
			SongNumber
		}
		public enum ChineseLanguage
		{
			Traditional,
			Simplified
		}
		public enum InfoType
		{
			NoAction,
			WorshipList,
			PreviewItem,
			OutputItemSlide1,
			OutputItemLastSlide,
			FormatStringUpdate,
			Save
		}
		public enum ItemSource
		{
			SongsList,
			ExternalFileInfoScreen = 2,
			ExternalFileMedia,
			ExternalFilePowerpoint,
			HolyBible,
			WorshipList,
			PraiseBook,
			TextFile
		}
		public enum ItemIcon
		{
			DB,
			DBBracket,
			PP,
			PPBracket,
			HB,
			HBBracket,
			TX,
			TXBracket,
			INF,
			INFBracket,
			WD,
			WDBracket,
			SingleScreen,
			DualScreen,
			Keyboard,
			BlackScreen,
			BlackScreenFramed,
			BlueScreen,
			BlueScreenFramed,
			MD = 28,
			MDBracket,
			LiveCam,
			LiveCamFramed
		}
		public enum HB
		{
			VersionNo,
			Name,
			Description,
			Copyright,
			FullPathFilename,
			SongFolder,
			PercentFontSize
		}
		public enum HBMatch
		{
			All,
			Any,
			Exact
		}
		public enum HBLoc
		{
			VersionNo,
			Book,
			Chapter,
			Verse,
			Start,
			Length
		}
		public enum SongsItem
		{
			IDString,
			Type,
			Title,
			FirstChar,
			FormatString
		}
		public enum KeyDirection
		{
			FirstOne,
			PrevOne,
			NextOne,
			LastOne,
			Refresh
		}
		public enum PicFolder
		{
			Name,
			Path
		}
		public enum MPCType
		{
			Session,
			Individual
		}
		public class SongSettings
		{
			public class SongFormat
			{
				public string FormatString = "";
				public string DBStoredFormat = "";
				public string[] HeaderData = new string[255];
				public int ShowSongHeadings = 1;
				public int ShowSongHeadingsAlign = 0;
				public int ShowLyrics = 1;
				public gf.ImageMode BackgroundMode = gf.ImageMode.BestFit;
				public Color[] ShowScreenColour = new Color[2];
				public Color[] ShowFontColour = new Color[2];
				public int ShowScreenStyle = 0;
				public int UseShadowFont = 1;
				public int UseOutlineFont = 1;
				public int ShowInterlace = 0;
				public int ShowVerticalAlign = 1;
				public int ShowLeftMargin;
				public int ShowRightMargin;
				public int ShowBottomMargin;
				public int ShowNotations = 0;
				public int HideDisplayPanel = 0;
				public int[] ShowFontBold = new int[4];
				public int[] ShowFontItalic = new int[4];
				public int[] ShowFontUnderline = new int[4];
				public int[] ShowFontRTL = new int[2];
				public int[] ShowFontAlign = new int[2];
				public string[] ShowFontName = new string[2];
				public int[] ShowFontVPosition = new int[2];
				public int[] ShowFontSize = new int[2];
				public int[] ShowBibleFontSize = new int[2];
				public int TransposeOffset;
				public int PreviousTransposeOffset;
				public string BackgroundPicture;
				public int MediaOption;
				public string MediaLocation;
				public int MediaCaptureDeviceNumber;
				public int MediaVolume = 50;
				public int MediaBalance = 0;
				public int MediaMute = 0;
				public int MediaRepeat = 0;
				public int MediaWidescreen = 0;
				public bool MediaTransparent = false;
				public string ImageString = "";
				public string TempImageFileName = "";
				public int ShowItemTransition;
				public int ShowSlideTransition;
			}
			public class SongLyrics
			{
				public Font Font;
				public Font ChorusFont;
				public Font FS_Font;
				public Font FS_ChorusFont;
				public StringAlignment TextAlign;
				public bool Shadow = true;
				public bool Transparent = true;
				public Color BackColour = default(Color);
				public Color ForeColour = default(Color);
				public string Text = "";
				public bool Visible = true;
				public int Left;
				public int Top;
				public int Width;
				public int Height;
				public int Height_R2Bound;
				public int FS_Left;
				public int FS_Top;
				public int FS_Width;
				public int FS_Height;
				public int FS_Height_R2Bound;
				public int FS_TopOffset;
				public int FS_ComputedHeight;
				public int FS_OneLyricAndNotationHeight;
				public int FS_InterlaceGapHeight;
				public string FS_InterlaceLinePattern = "";
				public void Initialise()
				{
					this.TextAlign = StringAlignment.Center;
					this.Shadow = false;
					this.ForeColour = gf.DefaultForeColour;
					this.Text = "";
					this.Visible = true;
					this.Left = 0;
					this.Top = 0;
					this.Width = 0;
					this.Height = 0;
					this.FS_Left = 0;
					this.FS_Top = 0;
					this.FS_Width = 0;
					this.FS_Height = 0;
					this.FS_TopOffset = 0;
					this.FS_OneLyricAndNotationHeight = 0;
				}
			}
			public gf.ItemSource Source;
			public ListView LyricsAndNotationsList = new ListView();
			public string ItemID = "";
			public string InMainItemText = "";
			public string InSubItemItem1Text = "";
			public string Type = "";
			public string Title = "";
			public string Title2 = "";
			public int SongNumber = -1;
			public int FolderNo = 0;
			public int HBR2_FolderNo = 0;
			public string Path = "";
			public string AllLyrics = "";
			public string Notations = "";
			public string OriginalNotations = "";
			public int FontSizeFactor = 0;
			public int HBR2_FontSizeFactor = 0;
			public int Capo = -1;
			public string Copyright = "";
			public string FolderName = "";
			public string Writer = "";
			public string Category = "";
			public string Book_Reference = "";
			public string User_Reference = "";
			public string Timing = "";
			public string MusicKey = "";
			public string RotateString = "";
			public int RotateStyle = 1;
			public int RotateGap = 0;
			public int RotateTotal = 0;
			public string RotateTimings = "";
			public string RotateSequence = "";
			public string Settings = "";
			public int CurSlide = 0;
			public bool CurSlideIsVerse = false;
			public int TotalSlides = 0;
			public bool OutputStyleScreen = false;
			public bool AtLiveScreen = false;
			public int[,] Slide = new int[1001, 8];
			public bool UseDefaultFormat = true;
			public int CurItemNo = 0;
			public int TotalItems = 0;
			public string CompleteLyrics = "";
			public bool FirstShowing = true;
			public bool SplitScreens = true;
			public bool Show_BookName = true;
			public bool Show_LicAdim = true;
			public string Show_LicAdminInfo1 = "";
			public string Show_LicAdminInfo2 = "";
			public string In_LicAdminInfo1 = "";
			public string In_LicAdminInfo2 = "";
			public gf.SongSettings.SongLyrics[] Lyrics = new gf.SongSettings.SongLyrics[4];
			public string SongSequence = "";
			public string SongBasicSequence = "";
			public string SongOriginalLoadedSequence = "";
			public int[] SongVerses = new int[100];
			public int[] ChorusSlides = new int[10];
			public bool Verse2Present = false;
			public bool[] VersePresent = new bool[160];
			public int[,] VerseLineLoc = new int[160, 5];
			public bool PrevItemPP = false;
			public string PrevTitle = "";
			public string NextTitle = "";
			public bool GapItemOnDisplay = false;
			public gf.SongSettings.SongFormat Format = new gf.SongSettings.SongFormat();
			public void Initialise()
			{
				gf.SetListViewColumns(this.LyricsAndNotationsList, 6);
				this.Title = "";
				this.Copyright = "";
				this.TotalSlides = 0;
				this.CurSlide = 1;
				this.SongNumber = 0;
				this.Book_Reference = "";
				this.User_Reference = "";
				this.Capo = -1;
				this.FirstShowing = true;
				gf.SongSettings.SongFormat songFormat = new gf.SongSettings.SongFormat();
				songFormat.ShowSongHeadings = 1;
				songFormat.ShowVerticalAlign = 1;
				songFormat.ShowLeftMargin = 2;
				songFormat.ShowRightMargin = 2;
				songFormat.ShowBottomMargin = 0;
				songFormat.ShowLyrics = 2;
				songFormat.BackgroundMode = gf.ImageMode.BestFit;
				this.RotateString = "";
				songFormat.ShowItemTransition = 15;
				songFormat.ShowSlideTransition = 0;
				this.UseDefaultFormat = true;
				this.CompleteLyrics = "";
				this.FontSizeFactor = 100;
				this.Verse2Present = false;
				this.OutputStyleScreen = false;
				this.Show_BookName = false;
				this.Show_LicAdim = true;
				this.Show_LicAdminInfo1 = "";
				this.Show_LicAdminInfo2 = "";
				this.In_LicAdminInfo1 = "";
				this.In_LicAdminInfo2 = "";
				this.Lyrics[0] = new gf.SongSettings.SongLyrics();
				this.Lyrics[1] = new gf.SongSettings.SongLyrics();
				this.Lyrics[2] = new gf.SongSettings.SongLyrics();
				this.Lyrics[3] = new gf.SongSettings.SongLyrics();
				this.Lyrics[0].Initialise();
				this.Lyrics[1].Initialise();
				this.Lyrics[2].Initialise();
				this.Lyrics[3].Initialise();
			}
		}
		[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto, Pack = 1)]
		public struct SHFILEOPSTRUCT
		{
			public IntPtr hwnd;
			public uint wFunc;
			public string pFrom;
			public string pTo;
			public ushort fFlags;
			public int fAnyOperationsAborted;
			public IntPtr hNameMappings;
			[MarshalAs(UnmanagedType.LPWStr)]
			public string lpszProgressTitle;
		}
		public const string EasiSlides_Version = "4.0.5";
		public const string Database_Version = "4.0B";
		public const string MainRelease = "";
		public const string EasiSlides_Copyright = "2003-2010 Wai Kuen Mo";
		public const string RegAppLoc = "Software";
		public const string RegAppName = "EasiSlides";
		public const string RegAppFullName = "Software\\EasiSlides";
		public const int HeaderVersion = 320;
		public const string Reg_Config = "config";
		public const string Reg_Settings = "settings";
		public const string Reg_Options = "options";
		public const string Reg_Monitors = "monitors";
		public const string Reg_MainEditList = "maineditlist";
		public const string Reg_EditorEditList = "editoreditlist";
		public const string Reg_InfoScreenEditList = "infoscreeneditlist";
		public const string ESFormatSymEnd = "]";
		public const string ESFormatSymStart = "[";
		public const string WDFileSym = "W";
		public const string INFileSym = "I";
		public const string TXFileSym = "T";
		public const string BIFileSym = "B";
		public const string PPFileSym = "P";
		public const string DBFileSym = "D";
		public const string MDFileSym = "M";
		public const string GAFileSym = "G";
		public const string MusicSym = " <#>";
		public const string WorshipListOutputIndicator = "O";
		public const char NotationsSeparator = ';';
		public const char FieldSeparator = '>';
		public const string FieldSeparatorString = ">";
		public const char HBSeparator = ';';
		public const char BibleverseSym0 = ':';
		public const char BibleverseSym1 = '.';
		public const char BibleverseSym2 = 'v';
		public const char BibleverseSym3 = 'V';
		public const string SQLWildCard = "%";
		public const string DAOWildCard = "*";
		public const char ESSongFormatSym = '*';
		public const char ESSequenceSeparator = ',';
		public const string ESFormatNotation = "[~";
		public const string ESFormatSeq = "[@";
		public const string ESFormatTitle = "[>";
		public const string ESFormatSubNotationStart = "(";
		public const string ESFormatSubNotationEnd = ")";
		public const string RTF_Ext = ".rtf";
		public const string TEXT_Ext = ".txt";
		public const string Info_Ext = ".esi";
		public const string WORD_Ext = ".doc";
		public const string PP_Ext = ".ppt";
		public const string ESText32_Ext = ".est";
		public const string ESText_Ext = ".esn";
		public const string ESFT_Ext = ".esft";
		public const string ESF_Ext = ".esf";
		public const string XML_Ext = ".xml";
		public const string OldList_Ext = ".dat";
		public const string EST_Ext = ".est";
		public const string ESW_Ext = ".esw";
		public const string ESP_Ext = ".esp";
		public const string Access_Ext = ".mdb";
		public const string WebPage_Ext = ".htm";
		public const string NotationSym = "»";
		public const string MusicFlat = "b";
		public const string MusicSharp = "#";
		public const string vbLf = "\n";
		public const string vbCr = "\r";
		public const string vbTab = "\t";
		public const string vbvTab = "\v";
		public const string vbCrLf = "\r\n";
		public const string est31SongTitle = "[>";
		public const string est31SongTitle2 = ">>";
		public const string est31SongFolder = ">f";
		public const string est31SongCopyright = ">c";
		public const string est31BookReference = ">r";
		public const string est31UserReference = ">u";
		public const string est31SongWriterInfo = ">w";
		public const string est31SongKey = ">k";
		public const string est31SongTiming = ">t";
		public const string est31SongCapo = ">0";
		public const string est31SongNumber = ">n";
		public const string est31SongAdmin1 = ">a";
		public const string est31SongAdmin2 = ">b";
		public const string est31Sequence = ">@";
		public const string est31SongFormat = ">q";
		public const string Reg_RootEasiSlidesDir = "root_directory";
		public const string Reg_CurSession = "current_session";
		public const string Reg_CurPraiseBook = "current_praisebook";
		public const string Reg_ExportToDir = "export_dir";
		public const string Reg_ImportFromDir = "import_dir";
		public const string Reg_MediaDir = "media_dir";
		public const string Reg_PraiseOutputDir = "praiseoutput_dir";
		public const string Reg_RegKey = "RegistrationNumber";
		public const string Reg_RegUser = "RegistrationUser";
		public const string Reg_UseSongNumbers = "UseSongNumbers";
		public const string Reg_PrinterSpaces = "PrinterSpaces";
		public const string Reg_LicAdminCCLINo = "licCCLI_no";
		public const string Reg_LicAdmin4No = "lic4_no";
		public const string Reg_LicAdmin5No = "lic5_no";
		public const string Reg_LicAdmin6No = "lic6_no";
		public const string Reg_LicAdmin7No = "lic7_no";
		public const string Reg_LicAdmin8No = "lic8_no";
		public const string Reg_LicAdminNoSymbol = "licNoSym";
		public const string Reg_LicAdminEnforceDisplay = "licEnforceDisplay";
		public const string Reg_HB_MaxVersesSelection = "BibleMaxSelectVerses";
		public const string Reg_HB_MaxAdhocVersesSelection = "BibleMaxAdhocVersesSelection";
		public const string Reg_HB_ShowVerses = "BibleShowVerses";
		public const string Reg_PP_MaxFiles = "PowerpointMaxFiles";
		public const string Reg_MaxEditHistory = "MaxEditHistory";
		public const string Reg_UsePowerpointTab = "UsePowerpointTab";
		public const string Reg_NoPowerpointPanelOverlay = "NoPowerpointPanelOverlay";
		public const string Reg_UseMediaTab = "UseMediaTab";
		public const string Reg_ShowLyricsMonitorAlertBox = "ShowLyricsMonitorAlertBox";
		public const string Reg_NoMediaPanelOverlay = "NoMediaPanelOverlay";
		public const string Reg_AutoTextOverflow = "AutoTextOverflow";
		public const string Reg_UseLargestFontSize = "UseLargestFontSize";
		public const string Reg_AdvanceNextItem = "AdvanceNextItem";
		public const string Reg_LineBetweenRegions = "LineBetweenRegions";
		public const string Reg_GapItemOption = "GapItemOption";
		public const string Reg_GapItemLogoFile = "GapItemLogoFile";
		public const string Reg_GapItemUseFade = "GapItemUseFade";
		public const string Reg_KeyBoardOption = "KeyBoardOption";
		public const string Reg_OutputMonitorNo = "OutputmonitorNumber";
		public const string Reg_LyricsMonitorNo = "LyricsMonitorNumber";
		public const string Reg_PreviewAreaShowNotations = "PreviewAreaShowNotations";
		public const string Reg_PreviewAreaLineBetweenScreens = "PreviewAreaLineBetweenScreens";
		public const string Reg_PreviewAreaFontSize = "PreviewAreaFontSize";
		public const string Reg_BibleTextFontSize = "BibleTextFontSize";
		public const string Reg_EditMainFontName = "EditMainFontName";
		public const string Reg_EditMainFontSize = "EditMainFontSize";
		public const string Reg_EditNotationFontSize = "EditNotationFontSize";
		public const string Reg_InfoMainFontName = "InfoMainFontName";
		public const string Reg_InfoMainFontSize = "InfoMainFontSize";
		public const string Reg_InfoMainShowAllButtons = "InfoMainShowAllButtons";
		public const string Reg_EditOpenDocumentDir = "EditOpenDocumentDir";
		public const string Reg_ShowRotateGap = "RotateGap";
		public const string Reg_WordWrapLeftAlignIndent = "WordWrapLeftAlignIndent";
		public const string Reg_WordWrapIgnoreStartSpaces = "WordWrapIgnoreStartSpaces";
		public const string Reg_ParentalAlertHeading = "ParentalAlertHeading";
		public const string Reg_ParentalAlertDuration = "ParentalAlertDuration";
		public const string Reg_ParentalAlertTextColour = "ParentalAlertTextColour";
		public const string Reg_ParentalAlertBackColour = "ParentalAlertBackColour";
		public const string Reg_ParentalAlertTextAlign = "ParentalAlertTextAlign";
		public const string Reg_ParentalAlertVerticalAlign = "ParentalAlertVerticalAlign";
		public const string Reg_ParentalAlertStyle = "ParentalAlertStyle";
		public const string Reg_ParentalAlertFontName = "ParentalAlertFontName";
		public const string Reg_ParentalAlertFontSize = "ParentalAlertFontSize";
		public const string Reg_ParentalAlertFontFormat = "ParentalAlertFontFormat";
		public const string Reg_DMAlwaysUse = "AlwaysTryDualMonitor";
		public const string Reg_DMOption = "DualMonitorOption";
		public const string Reg_DMOptionCusLeft = "DualMonitorOptionCustomLeft";
		public const string Reg_DMOptionCusTop = "DualMonitorOptionCustomTop";
		public const string Reg_DMOptionCusWidth = "DualMonitorOptionCustomWidth";
		public const string Reg_DMOptionCusAsSingleMonitor = "DualMonitorOptionCustomAsSingle";
		public const string Reg_DisableSreenSaver = "DisableSreenSaver";
		public const string Reg_VideoSize = "VideoSize";
		public const string Reg_VideoVAlign = "VideoVAlign";
		public const string Reg_LMAlwaysUse = "AlwaysTrySecondaryLyricsMonitor";
		public const string Reg_LMOption = "LyricsMonitorOption";
		public const string Reg_LMOptionCusLeft = "LyricsMonitorOptionCustomLeft";
		public const string Reg_LMOptionCusTop = "LyricsMonitorOptionCustomTop";
		public const string Reg_LMOptionCusWidth = "LyricsMonitorOptionCustomWidth";
		public const string Reg_LMTextColour = "LyricsMonitorTextColour";
		public const string Reg_LMHighlightColour = "LyricsMonitorHighlightColour";
		public const string Reg_LMBackColour = "LyricsMonitorBackColour";
		public const string Reg_LMShowNotations = "LyricsMonitorShowNotations";
		public const string Reg_LMFontSize = "LyricsMonitorFontSize";
		public const string Reg_LMNotationsFontSize = "LyricsMonitorNotationsFontSize";
		public const string Reg_LMFontFormat = "LyricsMonitorFontFormat";
		public const string Reg_FocusedTextRegionColour = "FocusedBackColour";
		public const string Reg_TextRegionSlideTextColour = "SelectedSlideTextColour";
		public const string Reg_TextRegionSlideBackColour = "SelectedSlideBackColour";
		public const string Reg_UseFocusedTextRegionColour = "UseFocusedBackColour";
		public const string Reg_JumpToA = "JumpToA";
		public const string Reg_JumpToB = "JumpToB";
		public const string Reg_JumpToC = "JumpToC";
		public const string Reg_MessageAlertDuration = "MessageAlertDuration";
		public const string Reg_MessageAlertTextColour = "MessageAlertTextColour";
		public const string Reg_MessageAlertBackColour = "MessageAlertBackColour";
		public const string Reg_MessageAlertTextAlign = "MessageAlertTextAlign";
		public const string Reg_MessageAlertVerticalAlign = "MessageAlertVerticalAlign";
		public const string Reg_MessageAlertStyle = "MessageAlertStyle";
		public const string Reg_MessageAlertFontName = "MessageAlertFontName";
		public const string Reg_MessageAlertFontSize = "MessageAlertFontSize";
		public const string Reg_MessageAlertFontFormat = "MessageAlertFontFormat";
		public const string Reg_ReferenceAlertDuration = "ReferenceAlertDuration";
		public const string Reg_ReferenceAlertTextColour = "ReferenceAlertTextColour";
		public const string Reg_ReferenceAlertBackColour = "ReferenceAlertBackColour";
		public const string Reg_ReferenceAlertTextAlign = "ReferenceAlertTextAlign";
		public const string Reg_ReferenceAlertVerticalAlign = "ReferenceAlertVerticalAlign";
		public const string Reg_ReferenceAlertStyle = "ReferenceAlertStyle";
		public const string Reg_ReferenceAlertFontName = "ReferenceAlertFontName";
		public const string Reg_ReferenceAlertFontSize = "ReferenceAlertFontSize";
		public const string Reg_ReferenceAlertFontFormat = "ReferenceAlertFontFormat";
		public const string Reg_ReferenceAlertSource = "ReferenceAlertSource";
		public const string Reg_ReferenceAlertUsePick = "ReferenceAlertUsePick";
		public const string Reg_ReferenceAlertBlankIfPickNotFound = "ReferenceAlertBlankIfPickNotFound";
		public const string Reg_ReferenceAlertPickName = "ReferenceAlertPickName";
		public const string Reg_ReferenceAlertPickSubstitute = "ReferenceAlertPickSubstitute";
		public const string Reg_ReferenceAlertPickSeparator = "ReferenceAlertPickSeparator";
		public const string Reg_HTMLPublisher = "HTML_Publisher";
		public const string Reg_HTMLWeb = "HTML_Web";
		public const string Reg_HTMLInfo1 = "HTML_Info1";
		public const string Reg_HTMLMusicLink = "HTML_Musiclink";
		public const string Reg_HTMLShowIndex = "HTML_ShowIndex";
		public const string Reg_HTMLShowNumbers = "HTML_ShowNumbers";
		public const string Reg_HTMLShowChorusItalics = "HTML_ShowChorusItalics";
		public const string Reg_HTMLShowBookRef = "HTML_ShowBookReference";
		public const string Reg_HTMLShowUserRef = "HTML_ShowUserReference";
		public const string Reg_HTMLDoubleByte = "HTML_DoubleByte";
		public const string Reg_HTMLDocumentOption = "HTML_DocumentOption";
		public const string Reg_HTMLRTFFontSize = "HTML_RTFFontSize";
		public const string Reg_OutlineFontSizeThreshold = "OutlineFontSizeThreshold";
		public const string Reg_ExportExtension = "export_ext";
		public const string Reg_AutoRotateOn = "AutoRotateOn";
		public const string Reg_AutoRotateStyle = "AutoRotateStyle";
		public const string Reg_NotationFontFactor = "NotationFontFactor";
		public const string Reg_ExternalListing = "ExternalListing";
		public const string Reg_LiveCamNumber = "LiveCamNumber";
		public const string Reg_LiveCamMute = "LiveCamMute";
		public const string Reg_LiveCamVolume = "LiveCamVolume";
		public const string Reg_LiveCamBalance = "LiveCamBalance";
		public const string Reg_LiveCamWidescreen = "LiveCamWidescreen";
		public const string Reg_LiveCamNoPanelOverlay = "LiveCamNoPanelOverlay";
		public const string SansSerifString = "Microsoft Sans Serif";
		public const string MediaCaptureSymbol = "<<Capture>>";
		public const string DrawLineSymbol = "<<DrawLine>>";
		public const int BIBLE_MODE = 3;
		public const int INVALID_HANDLE_VALUE = -1;
		public const int MAX_SONGS = 20000;
		public const int MAX_VERSES = 9;
		public const int MIN_SCREEN_WIDTH = 9600;
		public const int SongOptNoMusic = 2;
		public const int SongOptMusic = 1;
		public const int SongOptAll = 0;
		public const int DB_MAXSLIDES = 1000;
		public const int MAXSONGSFOLDERS = 41;
		public const int DB_MAXVERSESADD = 3;
		public const int DB_MAXVERSES = 99;
		public const int DB_MAXHEADINGTYPES = 4;
		public const int NOTE = 152;
		public const int NEWSCREEN = 151;
		public const int REGION2 = 150;
		public const int PRECHORUS2 = 112;
		public const int PRECHORUS = 111;
		public const int CHORUS2 = 102;
		public const int ENDING = 101;
		public const int BRIDGE = 100;
		public const int BRIDGE2 = 103;
		public const int CHORUS = 0;
		public const int DB_MAXVERSESARRAY = 160;
		public const int DB_DELFOLDER = 0;
		public const int LIST_ADD = 1;
		public const int LIST_RENAME = 2;
		public const int FOLDER_RENAME = 3;
		public const int PRAISEBOOK_ADD = 4;
		public const int PRAISEBOOK_RENAME = 5;
		public const int INFOSCREEN_NAME = 6;
		public const int LIST_COPY_AS_PRAISEBOOK = 7;
		public const int LIST_COPY_AS_WORSHIPLIST = 8;
		public const int SONG_MOVE = 3;
		public const int SONG_RECOVER = 2;
		public const int SONG_DELETE = 1;
		public const int RTB_IU = 7;
		public const int RTB_BIU = 6;
		public const int RTB_BU = 5;
		public const int RTB_BI = 4;
		public const int RTB_U = 3;
		public const int RTB_I = 2;
		public const int RTB_B = 1;
		public const int RTB_NORMAL = 0;
		public const int MAX_FILENAME_LEN = 260;
		public const string DelimitSym = ">";
		public const string ShowSettingSym = ">";
		public const int SongNumberMaxLength = 6;
		public const string TextfileExt = ".txt";
		public const int MAX_PATH = 260;
		public const long ERROR_FILE_NO_ASSOCIATION = 31L;
		public const long ERROR_FILE_NOT_FOUND = 2L;
		public const long ERROR_PATH_NOT_FOUND = 3L;
		public const long ERROR_FILE_SUCCESS = 32L;
		public const long ERROR_BAD_FORMAT = 11L;
		public const int ShowInputMax = 19;
		public const int PraiseInputMax = 60;
		public const string HeaderDataSym = "=";
		public const int HeaderDataMax = 255;
		public const int UniPosOffset = 65536;
		public const int RTFIndentAmount = 400;
		public const int KEYEVENTF_KEYUP = 2;
		public const int VK_LWIN = 91;
		public const int MAXPictureGroups = 255;
		public const int ThumbDefaultHSpacing = 5;
		public const int ThumbDefaultVSpacing = 5;
		public const int ThumbRootTop = 30;
		public const string HeaderLine = "\n";
		public const int IND_MAX = 10;
		public const int MusicKeyMaxIndex = 11;
		public const int HB_MaxBooks = 66;
		public const int HB_MaxVersions = 250;
		public const int LicAdmin_Max = 9;
		public const int HB_PassagesMax = 3001;
		public const int MaxMusicFileExtensions = 3000;
		public const int MaxRefileSongs = 30000;
		public const int DefaultShowLeftMargin = 2;
		public const int DefaultShowRightMargin = 2;
		public const int DefaultShowBottomMargin = 0;
		public const int DefaultShowRotateGap = 0;
		public const double MainFontHeightFactor = 1.05;
		public const string NewCopyInfoScreenSym = "*NEW*";
		public const string DirSym = "\\";
		public const string DefaultEasiSlidesDir = "C:\\EasiSlides\\";
		public const string DefaultSysDir = "Admin\\";
		public const string DefaultWorshipDir = "Admin\\WorshipLists\\";
		public const string DefaultInfoScreenDirName = "InfoScreen Items";
		public const string DefaultInfoScreenDir = "InfoScreens\\";
		public const string DefaultPowerpointDirName = "Powerpoint Items";
		public const string DefaultPowerpointDir = "Powerpoint\\";
		public const string DefaultDBDir = "Admin\\Database\\";
		public const string DefaultHBDir = "HolyBibles\\";
		public const string DefaultPraiseBookDir = "Admin\\PraiseBooks\\";
		public const string DefaultTemplatesDir = "Admin\\Templates\\";
		public const string DefaultWorshipTemplatesDir = "Admin\\Templates\\WorshipListsTemplates\\";
		public const string DefaultSettingsTemplatesDir = "Admin\\Templates\\SettingsTemplates\\";
		public const string DefaultMediaDirName = "Media Files";
		public const string DefaultMediaDir = "Media\\";
		public const string DefaultImagesDirName = "Images";
		public const string DefaultImagesDir = "Images\\";
		public const string DefaultDocumentsDir = "Documents\\";
		public const string DefaultHTMLDir = "Html\\";
		public const string DefaultDBFilename = "EasiSlidesDb.mdb";
		public const string DefaultUsageFilename = "EsUsage.mdb";
		public const string DefaultBibleDBFilename = "EsBiblesList.mdb";
		public const string DefaultAlertsFilename = "Alerts.txt";
		public const string DefaultParentalFilename = "Parental.txt";
		public const string DefaultMediaExtensionFilename = "MediaExtensions.txt";
		public const string DefaultAudioExtensionFilename = "AudioExtensions.txt";
		public const string DefaultVideoExtensionFilename = "VideoExtensions.txt";
		public const float BorderWidthFactor = 0.04f;
		public const string MissingDBItemTitle = " <Error - Item Not Found>";
		public const int WM_SETREDRAW = 11;
		public const string XMLNode_EasiSlides = "EasiSlides";
		public const string XMLNode_SystemID = "SystemID";
		public const string XMLNode_Item = "Item";
		public const string XMLNode_ItemID = "ItemID";
		public const string XMLNode_ListItem = "ListItem";
		public const string XMLNode_ListHeader = "ListHeader";
		public const string XMLNode_Title1 = "Title1";
		public const string XMLNode_Title2 = "Title2";
		public const string XMLNode_Folder = "Folder";
		public const string XMLNode_SongNumber = "SongNumber";
		public const string XMLNode_Contents = "Contents";
		public const string XMLNode_Notations = "Notations";
		public const string XMLNode_Sequence = "Sequence";
		public const string XMLNode_Writer = "Writer";
		public const string XMLNode_Copyright = "Copyright";
		public const string XMLNode_Category = "Category";
		public const string XMLNode_CJKWordCount = "CJKWordCount";
		public const string XMLNode_CJKStrokeCount = "CJKStrokeCount";
		public const string XMLNode_Timing = "Timing";
		public const string XMLNode_MusicKey = "MusicKey";
		public const string XMLNode_Capo = "Capo";
		public const string XMLNode_LicenceAdmin1 = "LicenceAdmin1";
		public const string XMLNode_LicenceAdmin2 = "LicenceAdmin2";
		public const string XMLNode_BookReference = "BookReference";
		public const string XMLNode_UserReference = "UserReference";
		public const string XMLNode_FormatData = "FormatData";
		public const string XMLNode_Image = "Image";
		public const string XMLNode_Notes = "Notes";
		public const string XMLNode_Settings = "Settings";
		public const string ImageSubFolderScenery = "Scenery";
		public const string ImageSubFolderTiles = "Tiles";
		public const char SuperscriptTagEnd = '\u0098';
		public const int LiveCamMaxDevices = 5;
		private const int SWP_HIDEWINDOW = 128;
		private const int SWP_SHOWWINDOW = 64;
		private const int FO_DELETE = 3;
		private const int FOF_ALLOWUNDO = 64;
		private const int FOF_NOCONFIRMATION = 16;
		public const int SPI_GETSCREENSAVERRUNNING = 114;
		public const int SPI_GETSCREENSAVEACTIVE = 16;
		public const int SPI_SETSCREENSAVEACTIVE = 17;
		public const int SRCCOPY = 13369376;
		public const int SBS_HORZ = 0;
		public const int SBS_VERT = 1;
		public const int SBS_CTL = 2;
		public const int SBS_BOTH = 3;
		public const int WM_VSCROLL = 277;
		public const int WM_HSCROLL = 276;
		public const int SB_LINEUP = 0;
		public const int SB_LINEDOWN = 1;
		public const int SB_PAGEUP = 2;
		public const int SB_PAGEDOWN = 3;
		public const int SB_THUMBPOSITION = 4;
		public const int SB_THUMBTRACK = 5;
		public const int SB_TOP = 6;
		public const int SB_BOTTOM = 7;
		public const int SB_ENDSCROLL = 8;
		public const int EM_GETFIRSTVISIBLELINE = 206;
		public static string SystemID = "";
		public static bool ApplicationFirstRun = false;
		public static bool RestoreSongsDatabase = false;
		public static DateTime PerformanceStartTime;
		public static DateTime MusicBuildStartTime;
		public static TimeSpan MusicBuildLapseTime = new TimeSpan(0L);
		public static bool MusicBuildContinue = true;
		public static bool WorshipListIDOK = false;
		public static Patterns BackPattern = new Patterns();
		public static bool Def_Headings = false;
		public static bool Def_OutlineFont = false;
		public static bool Def_ShadowFont = false;
		public static bool Def_Interleave = false;
		public static bool Def_Notations = false;
		public static bool Def_CapoZero = false;
		public static int Def_Regions = 0;
		public static int Def_VerticalAlign = 0;
		public static int Def_BackroundImage = 0;
		public static int Def_R1Align = 0;
		public static int Def_R2Align = 0;
		public static int Def_MultiMediaMode = 0;
		public static bool Panel_ShowPanel = false;
		public static bool Panel_Totals = false;
		public static bool Panel_Slides = false;
		public static bool Panel_Title = false;
		public static bool Panel_Copyright = false;
		public static bool Panel_TextAsR1 = false;
		public static bool Panel_BackTransparent = false;
		public static bool SplashScreenCanClose = false;
		public static bool SplashScreenBack = false;
		public static bool SplashScreenFront = false;
		public static bool PreviewArea_ShowNotations = true;
		public static bool PreviewArea_LineBetweenScreens = true;
		public static int PreviewArea_FontSize = 8;
		public static int BibleText_FontSize = 8;
		public static string Def_FormatString = "";
		public static string ImportFolder_StartDir = "";
		public static string ImportFolder_FolderName = "";
		public static Color Def_BackColour1 = gf.BlackScreenColour;
		public static Color Def_BackColour2 = gf.BlackScreenColour;
		public static Color Def_BackColourPattern = gf.BlackScreenColour;
		public static Color Def_R1Colour = gf.BlackScreenColour;
		public static Color Def_R2Color = gf.BlackScreenColour;
		public static Color Panel_TextColour = gf.BlackScreenColour;
		public static Color Panel_BackColour = gf.BlackScreenColour;
		public static Color SelectedTextColour = Color.Red;
		public static Color NormalTextColour = gf.BlackScreenColour;
		public static Color SelectedTextBackgroundColour = gf.BlackScreenColour;
		public static Color NotationColour = Color.Blue;
		public static ImageTransitionControl GlobalImageCanvas = new ImageTransitionControl();
		public static bool RotateSlides = true;
		public static Color ButtonDefaultForeColour = gf.BlackScreenColour;
		public static Color ButtonPressedForeColour = Color.Red;
		public static string DashesString = "----";
		public static string DashesStringSubstitute = "£!¬~¬";
		public static bool DoRTBOnEnterEvent = false;
		public static ImageTransitionControl tempScreen = new ImageTransitionControl();
		public static int PatternTimerPeriod = 80;
		public static bool DisableTransitions = true;
		public static ListBox tempList = new ListBox();
		public static ListView ListViewNotations = new ListView();
		public static bool UseSongNumbers = false;
		public static int AssignAdminCount = 0;
		public static string AssignAdmin1 = "";
		public static string AssignAdmin2 = "";
		public static string[,] LyricsArray = new string[100000, 3];
		public static int LyricsArrayMax = 0;
		public static bool AutoFocusTextRegion = false;
		public static bool UseFocusedTextRegionColour = true;
		public static Color TransparentColour = Color.FromArgb(255, 16, 0, 16);
		public static Color CaptureTransparentColour = Color.FromArgb(255, 0, 0, 0);
		public static Color BlackScreenColour = Color.FromArgb(255, 0, 0, 0);
		public static Color FocusedTextRegionColour = Color.FromArgb(-2097921);
		public static Color NormalTextRegionBackColour = Color.Black;
		public static Color TextRegionSlideTextColour = Color.Red;
		public static Color TextRegionSlideBackColour = Color.Yellow;
		public static string[,] MediaFileExtension = new string[3000, 2];
		public static int TotalMediaFileExt = 0;
		public static int IndexFileVersion = 0;
		public static int JumpToA = 1;
		public static int JumpToB = 2;
		public static int JumpToC = 3;
		public static int SystemClientMode = 0;
		public static string SystemClientServerName = "";
		public static bool SystemClientServerConnected = false;
		public static int[,] ShowFontVPosition = new int[41, 2];
		public static int[,] ShowFontAlign = new int[41, 2];
		public static int[,] ShowFontSize = new int[41, 2];
		public static int[,] ShowFontBold = new int[41, 4];
		public static int[,] ShowFontItalic = new int[41, 4];
		public static int[,] ShowFontUnderline = new int[41, 4];
		public static int[,] ShowFontRTL = new int[41, 2];
		public static string[,] ShowFontName = new string[41, 2];
		public static int[] ShowLeftMargin = new int[41];
		public static int[] ShowRightMargin = new int[41];
		public static int[] ShowBottomMargin = new int[41];
		public static int ShowRotateGap = 0;
		public static int ShowDataDisplayPrevNext = 0;
		public static int ShowDataDisplayCopyright = 0;
		public static int ShowDataDisplayTitle = 0;
		public static int ShowDataDisplaySongs = 0;
		public static int ShowDataDisplaySlides = 0;
		public static string ShowDataDisplayFontName = "Microsoft Sans Serif";
		public static int ShowDataDisplayFontBold = 0;
		public static int ShowDataDisplayFontItalic = 0;
		public static int ShowDataDisplayFontUnderline = 0;
		public static int ShowDataDisplayFontShadow = 0;
		public static int ShowDataDisplayFontOutline = 0;
		public static int ShowDataDisplayIndicatorsFontSize = 11;
		public static int ShowVerticalAlign = 1;
		public static int ShowLyrics = 0;
		public static int ShowSongHeadings = 0;
		public static int ShowSongHeadingsAlign = 0;
		public static int ShowInterlace = 0;
		public static int ShowCapoZero = 0;
		public static int ShowNotations = 0;
		public static string OUTPPPrefix;
		public static string PREPPPrefix;
		public static string ExtPPrefix;
		public static int ExtPPrefix_Num = 0;
		public static int OUTPPSequence = 0;
		public static int PREPPSequence = 0;
		public static int ExtPPSequence = 0;
		public static string OUTPPFullPath = "";
		public static string PREPPFullPath = "";
		public static string ExtPPFullPath = "";
		public static bool UsePowerpointTab = false;
		public static bool NoPowerpointPanelOverlay = false;
		public static bool UseMediaTab = false;
		public static bool NoMediaPanelOverlay = false;
		public static bool ShowLyricsMonitorAlertBox = false;
		public static bool AutoTextOverflow = true;
		public static bool UseLargestFontSize = true;
		public static bool AdvanceNextItem = false;
		public static bool LineBetweenRegions = true;
		public static gf.GapType GapItemOption = gf.GapType.None;
		public static gf.GapType AltGapItemOption = gf.GapType.None;
		public static bool GapItemUseFade = true;
		public static string GapItemLogoFile = "";
		public static int KeyBoardOption = 0;
		public static int TotalMainEditHistory = 0;
		public static int MaxUserEditHistory = 10;
		public static int AbsoluteMaxHitoryItems = 20;
		public static string[,] TempEditHistoryList = new string[gf.AbsoluteMaxHitoryItems + 1, 2];
		public static string[,] MainEditHistoryList = new string[gf.AbsoluteMaxHitoryItems + 1, 2];
		public static int TotalEditorEditHistory = 0;
		public static string[,] EditorEditHistoryList = new string[gf.AbsoluteMaxHitoryItems + 1, 2];
		public static int TotalInfoScreenEditHistory = 0;
		public static string[,] InfoScreenEditHistoryList = new string[gf.AbsoluteMaxHitoryItems + 1, 2];
		public static string AlertsDataFile = "";
		public static string ParentalDataFile = "";
		public static int AlertGap = 200;
		public static string MediaExtensionsDatafile = "";
		public static string AudioExtensionsDatafile = "";
		public static string VideoExtensionsDatafile = "";
		public static bool FindItemsRequested = false;
		public static bool FindItemsFormOpen = false;
		public static int Options_SelectedTabIndex = 0;
		public static string CurFolderName = "";
		public static int HB_MaxVersesSelection = 10;
		public static int HB_MaxAdhocVersesSelection = 10;
		public static bool HB_ShowVerses = true;
		public static int PP_MaxFiles = 25;
		public static int OutputMonitorNumber = 1;
		public static int LyricsMonitorNumber = 0;
		public static string EditMainFontName;
		public static int EditMainFontSize = 12;
		public static int EditNotationFontSize = 10;
		public static string InfoMainFontName;
		public static int InfoMainFontSize = 12;
		public static int InfoNotationFontSize = 10;
		public static bool InfoMainShowAllButtons = false;
		public static string LicAdminNoSymbol = "#";
		public static bool LicAdminEnforceDisplay = true;
		public static string UserString = "";
		public static bool AlertFormOpen = false;
		public static bool AlertRestoreWindow = false;
		public static string ParentalAlertHeading = "Parental Alert:";
		public static int ParentalAlertDuration = 20;
		public static string ParentalAlertDetails = "";
		public static bool ParentalAlertLive = false;
		public static bool ParentalAlertRequested = false;
		public static int ParentalAlertTextAlign = 3;
		public static int ParentalAlertVerticalAlign = 2;
		public static Color ParentalAlertBackColour = Color.White;
		public static Color ParentalAlertTextColour = Color.Magenta;
		public static bool ParentalAlertScroll = true;
		public static bool ParentalAlertFlash = true;
		public static bool ParentalAlertTransparent = false;
		public static string ParentalAlertFontName = "";
		public static int ParentalAlertFontSize = 25;
		public static int ParentalAlertFontFormat = 0;
		public static bool ParentalAlertBold = false;
		public static bool ParentalAlertItalic = false;
		public static bool ParentalAlertUnderline = false;
		public static bool ParentalAlertShadow = false;
		public static bool ParentalAlertOutline = false;
		public static int MessageAlertDuration = 20;
		public static string MessageAlertDetails = "";
		public static bool MessageAlertLive = false;
		public static bool MessageAlertRequested = false;
		public static int MessageAlertTextAlign = 2;
		public static int MessageAlertVerticalAlign = 2;
		public static Color MessageAlertBackColour = Color.White;
		public static Color MessageAlertTextColour = gf.BlackScreenColour;
		public static bool MessageAlertScroll = true;
		public static bool MessageAlertFlash = true;
		public static bool MessageAlertTransparent = false;
		public static string MessageAlertFontName = "";
		public static int MessageAlertFontSize = 25;
		public static int MessageAlertFontFormat = 0;
		public static bool MessageAlertBold = false;
		public static bool MessageAlertItalic = false;
		public static bool MessageAlertUnderline = false;
		public static bool MessageAlertShadow = false;
		public static bool MessageAlertOutline = false;
		public static int ReferenceAlertDuration = 20;
		public static string ReferenceAlertDetails = "";
		public static bool ReferenceAlertLive = false;
		public static bool ReferenceAlertRequested = false;
		public static int ReferenceAlertTextAlign = 3;
		public static int ReferenceAlertVerticalAlign = 1;
		public static Color ReferenceAlertBackColour = Color.White;
		public static Color ReferenceAlertTextColour = gf.BlackScreenColour;
		public static bool ReferenceAlertScroll = true;
		public static bool ReferenceAlertFlash = false;
		public static bool ReferenceAlertTransparent = false;
		public static string ReferenceAlertFontName = "";
		public static int ReferenceAlertFontSize = 25;
		public static int ReferenceAlertFontFormat = 0;
		public static bool ReferenceAlertBold = false;
		public static bool ReferenceAlertItalic = false;
		public static bool ReferenceAlertUnderline = false;
		public static bool ReferenceAlertShadow = false;
		public static bool ReferenceAlertOutline = false;
		public static int ReferenceAlertSource = 0;
		public static bool ReferenceAlertUsePick = false;
		public static bool ReferenceAlertBlankIfPickNotFound = false;
		public static string ReferenceAlertPickName = "";
		public static string ReferenceAlertPickSubstitute = "";
		public static string ReferenceAlertPickSeparator = ",";
		public static Font ReferenceAlertFont = new Font("Microsoft Sans Serif", 30f);
		public static bool LyricsAlertRequested = false;
		public static string LyricsAlertDetails = "";
		public static int TotalMusicFiles = -1;
		public static string[,] MediaFilesList = new string[32000, 3];
		public static TimeSpan MediaPlayedLapseTime = new TimeSpan(0L);
		public static int OutlineFontSizeThreshold = 55;
		public static int AdjustedOutlineThreshold = 58;
		public static bool WMP_Present = false;
		public static string SymbolsString = "";
		public static int LiveCamNumber = 1;
		public static int LiveCamBalance = 0;
		public static int LiveCamVolume = 50;
		public static bool LiveCamMute = false;
		public static bool LiveCamWidescreen = false;
		public static bool LiveCamNoPanelOverlay = false;
		public static int AlertTimeRemaining = 0;
		public static bool DMAlwaysUse = true;
		public static int DMOption = 0;
		public static int DMOption1Left = 0;
		public static int DMOption1Top = 0;
		public static int DMOption1Width = 1;
		public static int DMOption1Height = 1;
		public static bool DMOption1AsSingleMonitor = false;
		public static bool DisableSreenSaver = true;
		public static bool LMAlwaysUse = true;
		public static int LMOption = 0;
		public static int LMOption1Left = 0;
		public static int LMOption1Top = 0;
		public static int LMOption1Width = 1;
		public static int LMOption1Height = 1;
		public static Color LMTextColour = gf.BlackScreenColour;
		public static Color LMHighlightColour = Color.Red;
		public static Color LMBackColour = Color.White;
		public static bool LMShowNotations = true;
		public static int LMMainFontSize = 20;
		public static int LMNotationsFontSize = 20;
		public static bool LMFontBold = false;
		public static bool LMFontUnderline = false;
		public static bool LMFontItalic = false;
		public static int LMFontFormat = 0;
		public static int ThumbImagesPerRow = 3;
		public static bool InfoScreen_RequestReceived = false;
		public static bool InfoScreenFormOpen = false;
		public static gf.InfoType InfoScreenAction = gf.InfoType.NoAction;
		public static string InfoScreenFileName = "";
		public static string InfoScreenEditTitle = "";
		public static string InfoScreenNewFormatString = "";
		public static string InfoScreenBackgroundPicture = "";
		public static bool InfoScreenLoadNewBackground = true;
		public static bool InfoScreenLoadItem = false;
		public static bool InfoScreenItemNew = false;
		public static bool EditorLoadItem = false;
		public static bool EditorFormOpen = false;
		public static int EditorItemID = 0;
		public static bool EditorItemNew = false;
		public static bool EditorItemFolderChanged = false;
		public static bool EditorItemTitleChanged = false;
		public static int EditorItemNewFolder = 0;
		public static string EditorItemTitle = "";
		public static string Import_Admin2ColumnName = "";
		public static string Import_Admin1ColumnName = "";
		public static string Import_SongTimingColumnName = "";
		public static string Import_SongNumberColumnName = "";
		public static string Import_SongKeyColumnName = "";
		public static string Import_UserReferenceColumnName = "";
		public static string Import_BookReferenceColumnName = "";
		public static string Import_SongCopyrightColumnName = "";
		public static string Import_SongWriterInfoColumnName = "";
		public static string Import_SongLyricsColumnName = "";
		public static string Import_SongTitle2ColumnName = "";
		public static string Import_SongTitleColumnName = "";
		public static string Import_TableName = "";
		public static string Import_AccessFileName = "";
		public static int SelectedItemsCount = 0;
		public static gf.SongSettings PreviewItem = new gf.SongSettings();
		public static gf.SongSettings OutputItem = new gf.SongSettings();
		public static gf.SongSettings LiveItem = new gf.SongSettings();
		public static gf.SongSettings LyricsItem = new gf.SongSettings();
		public static gf.SongSettings TempItem1 = new gf.SongSettings();
		public static gf.SongSettings TempItem2 = new gf.SongSettings();
		public static gf.SongSettings EditItem1 = new gf.SongSettings();
		public static gf.SongSettings EditItem2 = new gf.SongSettings();
		public static gf.SongSettings InfoItem1 = new gf.SongSettings();
		public static gf.SongSettings InfoItem2 = new gf.SongSettings();
		public static int LS_Height = 0;
		public static int LS_Width = 0;
		public static int LS_Top = 0;
		public static int LS_Left = 0;
		public static int Buffer_LS_Height = 0;
		public static int Buffer_LS_Width = 0;
		public static int LM_Height = 0;
		public static int LM_Width = 0;
		public static int LM_Top = 0;
		public static int LM_Left = 0;
		public static int PreviewSampleFactor = 1;
		public static int PP_TempNum = 0;
		public static int PP_SlidesCount = 0;
		public static int PP_SlidesNum = 0;
		public static Color DefaultBackColour = Color.FromArgb(gf.ObjToInt(-16777056));
		public static Color DefaultForeColour = Color.FromArgb(gf.ObjToInt(-1));
		public static int AutoRotateStyle = 3;
		public static bool AutoRotateOn = true;
		public static bool RestartCurrentItem = false;
		public static bool RestartItemActioned = false;
		public static int PowerpointListingStyle = 0;
		public static bool Alert_Scroll = true;
		public static bool Alert_Flash = true;
		public static bool Alert_tempFlash = true;
		public static bool Alert_Transparent = true;
		public static int Alert_RestCount = 0;
		public static string Alert_OriginalMessage = "";
		public static string Alert_FormattedMessage = "";
		public static string Alert_FormatOriginalSequence = "";
		public static string Alert_FormatSequence = "";
		public static int Alert_MessageLength = 0;
		public static int Alert_FlashCount = 0;
		public static bool Alert_MessageDisplayed = false;
		public static Color Alert_TextColour = Color.Red;
		public static Color Alert_BackColour = Color.White;
		public static Color Alert_TempColour = Color.Red;
		public static int Alert_TextAlign = 3;
		public static int Alert_VerticalAlign = 2;
		public static bool Alert_NewMessage = true;
		public static Font Alert_UserFont = new Font("Microsoft Sans Serif", 30f);
		public static bool Alert_UserFontShadow = true;
		public static bool Alert_UserFontOutline = true;
		public static Font Alert_AdjustedFont = new Font("Microsoft Sans Serif", 30f);
		public static int Alert_MessageHeight = 0;
		public static int Alert_FontSize = 12;
		public static string Alert_Fontname = "";
		public static bool Alert_FontBold = false;
		public static bool Alert_FontItalic = false;
		public static bool Alert_FontUnderline = false;
		public static int ShowRunning_ShowVerticalAlign = 0;
		public static int ShowRunning_ShowInterlace = 0;
		public static int ShowRunning_ShowNotations = 0;
		public static int ShowRunning_ShowLyrics = 0;
		public static int ShowRunning_ShowSongHeadings = 0;
		public static int ShowRunning_UseOutlineFont = 0;
		public static int ShowRunning_UseShadowFont = 0;
		public static int ShowRunning_ShowDataDisplayMode = 0;
		public static bool LaunchShowUpdateDone = false;
		public static int LaunchShowLastItem = 0;
		public static int LaunchShowCurSlide = 0;
		public static bool TabSourceImagesChanged = false;
		public static bool TabSourceExternalFilesChanged = false;
		public static bool TabSourceMediaFolderFilesChanged = false;
		public static Color ChangedBackColour1 = gf.BlackScreenColour;
		public static Color ChangedBackColour2 = gf.BlackScreenColour;
		public static int ChangedBackStyle = 0;
		public static bool ChangedIsDefault = true;
		public static string popUpText = "";
		public static int popUpTextMaxLength = 100;
		public static string[] sArray;
		public static string[] xArray;
		public static RichTextBox tbWorkspace = new RichTextBox();
		public static RichTextBox tbTempSpace = new RichTextBox();
		public static RichTextBox tbLyricsMonitorSpace = new RichTextBox();
		public static RichTextBox tbLyricsNextItemSpace = new RichTextBox();
		public static int ShowBMargin = 0;
		public static int ShowRMargin = 0;
		public static int ShowLMargin = 0;
		public static int ShowLyricsWidth = 0;
		public static int HB_TotalVersions = 0;
		public static string[,] HB_Versions = new string[250, 7];
		public static int HB_CurVersionTabIndex = -1;
		public static int[,] HB_VersesLocation = new int[3001, 7];
		public static string Find_SQLString = "";
		public static string HB_SQLString = "";
		public static bool HB_UsingSearch = false;
		public static bool HB_SequentialListing = true;
		public static string HelpFile_Location;
		public static DBEngine DAODBEngine_definst = new DBEngineClass();
		public static bool LoadInitData = true;
		public static int MaxBackgroundStyleIndex;
		public static string HTMLPublisher;
		public static string HTMLWeb;
		public static string HTMLInfo1;
		public static bool HTMLMusicLink;
		public static bool HTMLShowIndex;
		public static bool HTMLShowChorusItalics;
		public static bool HTMLShowNumbers;
		public static bool HTMLShowBookRef;
		public static bool HTMLShowUserRef;
		public static bool HTMLDoubleByte;
		public static int HTMLDocumentOption;
		public static int HTMLRTFFontSize = 12;
		public static string FindSearchPhrase = "";
		public static string FindBibleSearchPhrase = "";
		public static int CurMainSelectedFolder = 1;
		public static int MusicSymLen = " <#>".Length;
		public static double TopBorderFactor = 0.022000000476837159;
		public static double MinBottomBorderFactor = 0.08;
		public static double BottomBorderFactor = 0.08;
		public static double RegionsGapFactor = 0.02;
		public static int ShowTopBorderSize;
		public static int ShowBottomBorderSize;
		public static int SearchOption = 0;
		public static string[] SequenceSymbol = new string[160];
		public static int[] Reg_NumArray = new int[9];
		public static string RootEasiSlidesDir;
		public static int[] PB_WordsUnderline = new int[8];
		public static int[] PB_WordsItalic = new int[8];
		public static int[] PB_WordsBold = new int[8];
		public static int[] PB_WordsSize = new int[8];
		public static int[] PB_ShowWords = new int[8];
		public static Color[] PB_WordsColour = new Color[8];
		public static gf.SortBy PB_CJKGroupStyle = gf.SortBy.Alpha;
		public static int PB_ShowScreenBreaks = 0;
		public static int PB_OneSongPerPage = 0;
		public static int[] PB_Spacing = new int[2];
		public static int PB_ShowColumns = 0;
		public static int PB_ShowSection = 0;
		public static int PB_LyricsPattern = 0;
		public static int PB_PageSize = 0;
		public static int[] PB_ShowHeadings = new int[4];
		public static string PB_DocumentName;
		public static string PB_FullFileName;
		public static gf.PraiseBookLayout PB_Layout = gf.PraiseBookLayout.WorshipList;
		public static int PB_PrinterSpaces = 0;
		public static int PB_CapoZero = 0;
		public static int PB_ShowCapo = 0;
		public static int PB_ShowKey = 0;
		public static int PB_ShowTiming = 0;
		public static int PB_ShowNotations = 0;
		public static int DB_CurSongID;
		public static string Edit_CurFolderTitle = "";
		public static bool Edit_RequestReceived = false;
		public static bool Edit_HistoryMaxChanged = false;
		public static string EditBible_Title;
		public static string EditBible_IDString;
		public static string[] VerseSymbol = new string[160];
		public static string[] VerseTitle = new string[160];
		public static string[] VerseFormatSymbol = new string[6];
		public static string EULA;
		public static bool PraiseBooksListChanged;
		public static bool WorshipListsChanged;
		public static bool NameChangeSucceeded;
		public static int FolderRenameNo = 0;
		public static int NameChangeAction = 0;
		public static string CurPraiseBook;
		public static string CurPraiseBookNotes = "";
		public static string[] FolderRenameName = new string[41];
		public static string SelectedListName;
		public static string InfoScreenDir;
		public static string PowerpointDir;
		public static string WorshipTemplatesDir;
		public static string SettingsTemplatesDir;
		public static string BibleDir;
		public static string ImagesDir;
		public static string PraiseOutputDir;
		public static string ImportFromDir;
		public static string ExportToDir;
		public static string DocumentsDir;
		public static string PraiseBookDir;
		public static string MediaDir;
		public static string EasiSlidesTempDir;
		public static string WorshipDir;
		public static string EditOpenDocumentDir;
		public static string CurSession;
		public static string CurSessionNotes = "";
		public static string EditNotes = "";
		public static string EditNotesHeading = "";
		public static string[,] FolderLyricsHeading = new string[41, 4];
		public static string[] FolderName = new string[41];
		public static int[] FolderHeadingPercentSize = new int[41];
		public static int[,] FolderHeadingFontBold = new int[41, 2];
		public static int[,] FolderHeadingFontItalic = new int[41, 2];
		public static int[,] FolderHeadingFontUnderline = new int[41, 2];
		public static int[] FolderHeadingOption = new int[41];
		public static double[,] ShowLineSpacing = new double[41, 2];
		public static int[] FolderUse = new int[41];
		public static gf.SortBy[] FolderGroupStyle = new gf.SortBy[41];
		public static int UseOutlineFont = 0;
		public static int UseShadowFont = 0;
		public static gf.ImageMode BackgroundMode = gf.ImageMode.Tile;
		public static int ShowSlideTransition = 0;
		public static int ShowItemTransition = 0;
		public static Color[] ShowFontColour = new Color[2];
		public static Color[] ShowScreenColour = new Color[2];
		public static int ShowScreenStyle = 0;
		public static string BackgroundPicture = "";
		public static int VideoSize = 100;
		public static int VideoVAlign = 1;
		public static string MediaLocation = "";
		public static string CurrentMediaLocation = "";
		public static bool CurrentMediaIsVideo = false;
		public static int MediaOption = 0;
		public static int MediaVolume = 50;
		public static int MediaBalance = 0;
		public static int MediaMute = 0;
		public static int MediaRepeat = 0;
		public static int MediaWidescreen = 0;
		public static int MediaCaptureDeviceNumber = 1;
		public static bool MediaNotifyRepeatItem = false;
		public static bool MediaCurrentItemIsVideo = false;
		public static bool MediaNotifyItemConnecting = false;
		public static bool MediaNotifyItemCannotPlay = false;
		public static bool MediaDoRotate = false;
		public static bool MediaResetStartTime = false;
		public static bool MediaLengthAsRotateLength = false;
		public static DateTime MediaLiveItemStartTime = default(DateTime);
		public static string Temp_MediaItemType = "";
		public static string Temp_MediaTitle1 = "";
		public static string Temp_MediaTitle2 = "";
		public static string Temp_MediaLocation = "";
		public static string Temp_MediaItemTitleLocation = "";
		public static int Temp_MediaOption = 0;
		public static int Temp_MediaVolume = 50;
		public static int Temp_MediaBalance = 0;
		public static int Temp_MediaMute = 0;
        public static int Temp_MediaPosition = 0;
		public static int Temp_MediaRepeat = 0;
		public static int Temp_MediaWidescreen = 0;
		public static int Temp_MediaCaptureDeviceNumber = 1;
		public static double[,] MainFontSpacingFactor = new double[41, 2];
		public static double NotationFontFactor = 0.75;
		public static string Lookup_NameSelected;
		public static string Lookup_NameBookRef;
		public static string Lookup_NameUserRef;
		public static bool SplashUp = true;
		public static bool FindBibleVerses;
		public static bool FindFolderItems;
		public static bool FindItemRestoreWindow = false;
		public static bool FindItemInTitle = true;
		public static bool FindItemInSongNumber = true;
		public static bool FindItemInBookRef = true;
		public static bool FindItemInUserRef = true;
		public static bool FindItemInContents = true;
		public static bool FindItemInWriter = false;
		public static bool FindItemInCopyright = false;
		public static bool FindItemInLicAdmin = false;
		public static bool FindItemMediaOnly = false;
		public static bool FindItemNotationsOnly = false;
		public static string FindItemWithKey = "";
		public static string FindItemWithTiming = "";
		public static bool FindItemUseDates = false;
		public static DateTime FindItemDateFrom;
		public static DateTime FindItemDateTo;
		public static int FindBibleBookIndex = 0;
		public static string tempDBFileName = "";
		public static string tempBiblesListFileName = "";
		public static string tempUsageFileName = "";
		public static string BiblesListFileName = "";
		public static string UsageFileName = "";
		public static string DBFileName = "";
		public static string ConnectStringDef = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=";
		public static string ConnectStringMainDB = "";
		public static string ConnectStringUsageDB = "";
		public static string ConnectStringBibleDB = "";
		public static string ExportFileName = "";
		public static string HBFilename = "";
		public static string ListingDirPath = "";
		public static string Listing_File_Name = "";
		public static int StartPresAt = 0;
		public static int Launch_StartPresAt = 0;
		public static bool AdHocItemPresent = false;
		public long MainFormHwnd = 0L;
		public static string[,] LicAdmin_List = new string[9, 3];
		public static string SFMPTSData = "";
		public static string BookRefData = "";
		public static bool[] FindSongsFolder = new bool[41];
		public static bool AllDirOK = false;
		public static bool AppCloseDown = false;
		public static string[,] WorshipSongs = new string[20000, 5];
		public static string[,] DocumentSongs = new string[20000, 5];
		public static int TotalWorshipListItems = 0;
		public static int TotalPraiseBookItems = 0;
		public static int TitlePosTop = 0;
		public static int TitleFontSize = 0;
		public static int ByteSize = 0;
		public static string Rename_String = "";
		public static string Rename_ExistingString = "";
		public static bool Options_MediaExtChanged = false;
		public static bool Options_MediaDirChanged = false;
		public static bool Options_MaxHistoryListChanged = false;
		public static bool Options_FolderListChanged = false;
		public static bool Options_FolderFormatChanged = false;
		public static bool Options_BibleListChanged = false;
		public static bool Options_PreviewAreaChanged = false;
		public static bool Options_DMChanged = false;
		public static int ShowDataDisplayMode;
		public static bool ShowRunning = false;
		public static Color PanelTextColour;
		public static Color PanelBackColour;
		public static int PanelTextColourAsRegion1 = 1;
		public static int PanelBackColourTransparent = 1;
		public static string SongFormatData = "";
		public static string[] FontsList = new string[2000];
		public static int FontsListMaxIndex = -1;
		public static string[] ShowInput = new string[60];
		public static string[] HeaderData = new string[255];
		public static string[] tempHeaderData = new string[255];
		public static bool SaveShowOptions;
		public static gf.UsageMode EasiSlidesMode = gf.UsageMode.Worship;
		public static int[] StrokeCount = new int[65536];
		public static bool PB_FormatChanged;
		public static string[] RTFIndent = new string[6];
		public static string RTFTab = "\\tab ";
		public static string RTFLineSpacing;
		public static string RTFNewLine;
		public static int[] RTFTabValue = new int[9];
		public static int MoveToFolder;
		public static int CopyToFolder;
		public static string ExternalMoveCopyType = "";
		public static int ExternalMoveFolder;
		public static int ExternalCopyFolder;
		public static string GenHTMLDir;
		public static string[,] PictureGroups = new string[255, 3];
		public static string[,] InfoScreenGroups = new string[255, 3];
		public static string[,] MediaGroups = new string[255, 3];
		public static string[,] PowerpointGroups = new string[255, 3];
		public static int InfoScreenFolderTotal = 0;
		public static int MediaFolderTotal = 0;
		public static int PowerpointFolderTotal = 0;
		public static int PicFolderTotal = 0;
		public static PP LivePP = new PP();
		public static PP PreviewPPT = new PP();
		public static PP OutputPPT = new PP();
		public static PP ExternalPPT = new PP();
		public static string[,] PowerpointList = new string[10000, 2];
		public static int TotalPowerpointItems = 0;
		public static bool ShowLiveBlack = false;
		public static bool ShowLiveClear = false;
		public static bool ShowLiveCam = false;
		public static bool WordWrapLeftAlignIndent = true;
		public static int WordWrapIgnoreStartSpaces = 8;
		public static bool DualMonitorMode = false;
		public static bool ShowDebugVideoMessages = false;
		public static string OutputMonitorText = "";
		public static string[] HBBookName = new string[67];
		public static string[] HBVersionBookName = new string[67];
		public UnicodeEncoding UnicodeEncoder = new UnicodeEncoding();
		public static string[] MusicMajorKeys = new string[14];
		public static string[] MusicMinorKeys = new string[14];
		public static string[,] MusicMajorChords = new string[13, 2];
		public static string[,] MusicMinorChords = new string[13, 2];
		public static int[] MusicMajorKeysFlatSharp = new int[14];
		public static int[] MusicMinorKeysFlatSharp = new int[14];
		public static bool TimerFlashOn = false;
		public static bool PreviewMouseHeldDown = false;
		public static bool OutputMouseHeldDown = false;
		public static bool LyricsMonitor_LyricsChanged = false;
		public static bool LyricsMonitor_WorshipListChanged = false;
		public static gf.KeyDirection MainAction_MoveToItemKeyDirection = gf.KeyDirection.Refresh;
		public static ImageTransitionControl.TransitionAction MainAction_SongChanged_Transaction = ImageTransitionControl.TransitionAction.AsStored;
		public static gf.MPCType MPC_Type = gf.MPCType.Session;
		public static string DefaultBackgroundID = "";
		public static object missing = Missing.Value;
		public static string[] NotationsArray = new string[32000];
		public static readonly object def = Missing.Value;
		public static bool PriorScreenSaverState = false;
		private gf()
		{
		}
		[DllImport("user32.dll")]
		private static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags);
		[DllImport("user32.dll", SetLastError = true)]
		private static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
		[DllImport("shell32.dll", EntryPoint = "FindExecutableA")]
		public static extern int FindExecutable(string lpFile, string lpDirectory, string lpResult);
		public static void HideTaskBar()
		{
			IntPtr hWnd = gf.FindWindow("Shell_TrayWnd", "");
			gf.SetWindowPos(hWnd, IntPtr.Zero, 0, 0, 0, 0, 128u);
		}
		public static void ShowTaskBar()
		{
			IntPtr hWnd = gf.FindWindow("Shell_TrayWnd", "");
			gf.SetWindowPos(hWnd, IntPtr.Zero, 0, 0, 0, 0, 64u);
		}
		[DllImport("shell32.dll", CharSet = CharSet.Auto)]
		public static extern int SHFileOperation(ref gf.SHFILEOPSTRUCT lpFileOp);
		[DllImport("user32.dll")]
		public static extern int SendMessage(IntPtr hwnd, uint msg, uint wParam, uint lParam);
		[DllImport("user32", CharSet = CharSet.Auto)]
		public static extern bool SystemParametersInfo(int uAction, int uParam, ref bool lpvParam, int fuWinIni);
		[DllImport("user32.dll")]
		public static extern bool InvalidateRect(IntPtr hwnd, IntPtr lpRect, bool bErase);
		[DllImport("Gdi32.dll")]
		public static extern IntPtr CreateCompatibleDC(IntPtr hdc);
		[DllImport("Gdi32.dll")]
		public static extern IntPtr CreateCompatibleBitmap(IntPtr hdc, int width, int height);
		[DllImport("Gdi32.dll")]
		public static extern IntPtr SelectObject(IntPtr hdc, IntPtr hgdiobj);
		[DllImport("gdi32.dll")]
		public static extern IntPtr DeleteDC(IntPtr hDc);
		[DllImport("gdi32.dll")]
		public static extern IntPtr DeleteObject(IntPtr hDc);
		[DllImport("gdi32.dll")]
		public static extern bool BitBlt(IntPtr hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, IntPtr hdcSrc, int nXSrc, int nYSrc, int dwRop);
		public static bool InitEasiSlidesDir()
		{
			gf.RootEasiSlidesDir = gf.GetRegValue("config", "root_directory", "C:\\EasiSlides\\");
			if (gf.RootEasiSlidesDir == "")
			{
				gf.RootEasiSlidesDir = "C:\\EasiSlides\\";
			}
			string regValue = gf.GetRegValue("config", "version", "none");
			string regValue2 = gf.GetRegValue("config", "database", "none");
			if (regValue != "4.0.5")
			{
				gf.SaveRegValue("config", "version", "4.0.5");
			}
			if (regValue2 != "4.0B")
			{
				gf.ApplicationFirstRun = true;
				gf.SaveRegValue("config", "database", "4.0B");
			}
			bool result;
			if (!gf.ValidateRootFolder())
			{
				result = false;
			}
			else
			{
				gf.SaveRegValue("config", "root_directory", gf.RootEasiSlidesDir);
				gf.ValidateID();
				gf.DBFileName = gf.RootEasiSlidesDir + "Admin\\Database\\EasiSlidesDb.mdb";
				bool flag = File.Exists(gf.DBFileName);
				if (gf.ApplicationFirstRun || !flag)
				{
					gf.CovertItemsTov4();
					if (!gf.RestoreSongsDatabase && gf.ApplicationFirstRun)
					{
						gf.SplashScreenBack = true;
						if (MessageBox.Show("Would you like to Install the EasiSlides Lyrics Database supplied with EasiSlides 4.0.5? Your existing Lyrics Database, if any, will be renamed and retained for backup.  Click Yes to Install, or No to continue using existing database.", "New EasiSlides Version 4.0.5 ... Replace existing Database with Supplied Database?", MessageBoxButtons.YesNo) == DialogResult.Yes)
						{
							gf.RestoreSongsDatabase = true;
						}
					}
					else
					{
						if (!gf.RestoreSongsDatabase && !flag)
						{
							gf.SplashScreenBack = true;
							if (MessageBox.Show("Cannot find the Lyrics Database.  Would you like to Install the EasiSlides Lyrics Database supplied with EasiSlides 4.0.5?  Click Yes to Install, or No to create a new blank database.", "Loading EasiSlides 4.0.5 ... Install Supplied Database?", MessageBoxButtons.YesNo) == DialogResult.Yes)
							{
								gf.RestoreSongsDatabase = true;
							}
						}
					}
				}
				if (gf.RestoreSongsDatabase)
				{
					string text = gf.RestoreOriginalSongsDatabase();
					if (text != "-1")
					{
						if (gf.ApplicationFirstRun)
						{
							if (text != "")
							{
								MessageBox.Show("Lyrics Database installed successfully. " + ((text != "") ? ("Existing database has been renamed to: " + text) : ""));
							}
						}
						else
						{
							MessageBox.Show("Lyrics Database installed successfully. " + ((text != "") ? ("Existing database has been renamed to: " + text) : ""));
						}
					}
				}
				gf.SplashScreenFront = true;
				result = true;
			}
			return result;
		}
		public static void CovertItemsTov4()
		{
			gf.WorshipDir = gf.RootEasiSlidesDir + "Admin\\WorshipLists\\";
			gf.RenameExtensions(gf.WorshipDir, ".dat", ".esw");
			gf.PraiseBookDir = gf.RootEasiSlidesDir + "Admin\\PraiseBooks\\";
			gf.RenameExtensions(gf.PraiseBookDir, ".dat", ".esp");
			string name = "music_dir";
			string regValue = gf.GetRegValue("config", name, gf.RootEasiSlidesDir + "Music\\");
			if (regValue == gf.RootEasiSlidesDir + "Music\\")
			{
				try
				{
					Directory.Move(regValue, gf.RootEasiSlidesDir + "Media\\");
					gf.SaveRegValue("config", "media_dir", gf.RootEasiSlidesDir + "Media\\");
				}
				catch
				{
				}
			}
			else
			{
				if (regValue != "")
				{
					gf.SaveRegValue("config", "media_dir", regValue);
				}
			}
			gf.DeleletRegKey("config", name);
			string text = gf.RootEasiSlidesDir + "Admin\\Database\\MusicExtensions.txt";
			string text2 = gf.RootEasiSlidesDir + "Admin\\Database\\MediaExtensions.txt";
			if (File.Exists(text) && !File.Exists(text2))
			{
				try
				{
					File.Move(text, text2);
				}
				catch
				{
				}
			}
			string text3 = gf.RootEasiSlidesDir + "User Images";
			string text4 = gf.RootEasiSlidesDir + "Images\\";
			if (Directory.Exists(text3) && !Directory.Exists(text4))
			{
				try
				{
					Directory.Move(text3, text4);
				}
				catch
				{
				}
			}
		}
		public static void MessageOverSplashScreen(string InString)
		{
			gf.SplashScreenBack = true;
			MessageBox.Show(InString);
			gf.SplashScreenBack = false;
		}
		public static void RenameExtensions(string InDir, string InOldExt, string InNewExt)
		{
			try
			{
				string[] files = Directory.GetFiles(InDir, "*" + InOldExt);
				string[] array = files;
				for (int i = 0; i < array.Length; i++)
				{
					string text = array[i];
					try
					{
						File.Move(text, InDir + "\\" + Path.GetFileNameWithoutExtension(text) + InNewExt);
					}
					catch
					{
					}
				}
			}
			catch
			{
			}
		}
		public static bool InitAppData()
		{
			gf.PerformanceStartTime = DateTime.Now;
			gf.LoadInitData = true;
			gf.LoadEulaText();
			bool result;
			if (!gf.LoadUnicodeStrokeCount())
			{
				result = false;
			}
			else
			{
				gf.HelpFile_Location = Application.StartupPath + "\\Sys\\EasiSlidesHelp.chm";
				gf.MusicSymLen = " <#>".Length;
				gf.MaxBackgroundStyleIndex = gf.BackPattern.MaxStyleIndex;
				gf.ShowScreenColour[0] = gf.DefaultBackColour;
				gf.ShowScreenColour[1] = gf.DefaultBackColour;
				gf.ShowScreenStyle = 0;
				gf.ShowFontColour[0] = gf.DefaultBackColour;
				gf.ShowFontColour[1] = gf.DefaultBackColour;
				for (int i = 1; i < 160; i++)
				{
					gf.VerseTitle[i] = "";
					gf.SequenceSymbol[i] = "";
				}
				gf.VerseTitle[0] = "chorus";
				for (int i = 1; i <= 99; i++)
				{
					gf.VerseTitle[i] = gf.ObjToString(i);
				}
				gf.VerseTitle[100] = "bridge";
				gf.VerseTitle[103] = gf.VerseTitle[100] + " 2";
				gf.VerseTitle[101] = "ending";
				gf.VerseTitle[102] = gf.VerseTitle[0] + " 2";
				gf.VerseTitle[111] = "prechorus";
				gf.VerseTitle[112] = gf.VerseTitle[111] + " 2";
				gf.VerseTitle[150] = "region 2";
				gf.VerseTitle[151] = "\n";
				gf.VerseTitle[152] = "note";
				gf.SymbolsString = "";
				for (int i = 1; i <= 99; i++)
				{
					gf.VerseSymbol[i] = "[" + gf.VerseTitle[i] + "]";
					gf.SequenceSymbol[i] = gf.VerseTitle[i];
					gf.SymbolsString = gf.SymbolsString + gf.VerseSymbol[i] + ",";
				}
				for (int i = 100; i < 160; i++)
				{
					gf.VerseSymbol[i] = "";
					gf.SequenceSymbol[i] = "";
				}
				gf.VerseSymbol[0] = "[" + gf.VerseTitle[0] + "]";
				gf.VerseSymbol[100] = "[" + gf.VerseTitle[100] + "]";
				gf.VerseSymbol[103] = "[" + gf.VerseTitle[103] + "]";
				gf.VerseSymbol[101] = "[" + gf.VerseTitle[101] + "]";
				gf.VerseSymbol[102] = "[" + gf.VerseTitle[102] + "]";
				gf.VerseSymbol[111] = "[" + gf.VerseTitle[111] + "]";
				gf.VerseSymbol[112] = "[" + gf.VerseTitle[112] + "]";
				gf.VerseSymbol[150] = "[" + gf.VerseTitle[150] + "]";
				gf.VerseSymbol[151] = gf.VerseTitle[151];
				gf.VerseSymbol[152] = "[" + gf.VerseTitle[152] + "]";
				gf.SequenceSymbol[0] = "c";
				gf.SequenceSymbol[100] = "b";
				gf.SequenceSymbol[103] = "w";
				gf.SequenceSymbol[101] = "e";
				gf.SequenceSymbol[102] = "t";
				gf.SequenceSymbol[111] = "p";
				gf.SequenceSymbol[112] = "q";
				string symbolsString = gf.SymbolsString;
				gf.SymbolsString = string.Concat(new string[]
				{
					symbolsString,
					gf.VerseSymbol[0],
					",",
					gf.VerseSymbol[102],
					",",
					gf.VerseSymbol[100],
					",",
					gf.VerseSymbol[103],
					",",
					gf.VerseSymbol[111],
					",",
					gf.VerseSymbol[112],
					",",
					gf.VerseSymbol[101],
					",",
					gf.VerseSymbol[150]
				});
				gf.xArray = gf.SymbolsString.Split(new char[]
				{
					','
				});
				gf.ShowLMargin = Screen.PrimaryScreen.Bounds.Width / 50;
				gf.ShowRMargin = gf.ShowLMargin;
				gf.ShowLyricsWidth = Screen.PrimaryScreen.Bounds.Width - gf.ShowLMargin - gf.ShowRMargin;
				gf.UsageFileName = gf.RootEasiSlidesDir + "Admin\\Database\\EsUsage.mdb";
				gf.BiblesListFileName = gf.RootEasiSlidesDir + "Admin\\Database\\EsBiblesList.mdb";
				gf.tempDBFileName = gf.RootEasiSlidesDir + "Admin\\Database\\~tempEasiSlidesDb.mdb";
				gf.tempUsageFileName = gf.RootEasiSlidesDir + "Admin\\Database\\~tempEsUsage.mdb";
				gf.tempBiblesListFileName = gf.RootEasiSlidesDir + "Admin\\Database\\~tempEsBiblesList.mdb";
				gf.ConnectStringMainDB = gf.ConnectStringDef + gf.DBFileName;
				gf.ConnectStringUsageDB = gf.ConnectStringDef + gf.UsageFileName;
				gf.ConnectStringBibleDB = gf.ConnectStringDef + gf.BiblesListFileName;
				gf.UserString = gf.Trim(gf.GetRegValue("config", "RegistrationUser", ""));
				if (!gf.ValidateVer_3_4_Fields())
				{
					result = false;
				}
				else
				{
					gf.LoadSavedData();
					gf.GenerateMusicKeysList();
					gf.SizeLaunchScreen();
					gf.ResetShowRunningSettings();
					gf.AlertsDataFile = gf.RootEasiSlidesDir + "Admin\\Database\\Alerts.txt";
					gf.ParentalDataFile = gf.RootEasiSlidesDir + "Admin\\Database\\Parental.txt";
					string startupPath = Application.StartupPath;
					gf.PreviewItem.Initialise();
					gf.OutputItem.Initialise();
					gf.LiveItem.Initialise();
					gf.LyricsItem.Initialise();
					gf.TempItem1.Initialise();
					gf.EditItem1.Initialise();
					gf.EditItem2.Initialise();
					gf.InfoItem1.Initialise();
					gf.InfoItem2.Initialise();
					gf.OutputItem.OutputStyleScreen = true;
					gf.SetListViewColumns(gf.ListViewNotations, 5);
					gf.LivePP.Init();
					gf.PreviewPPT.Init();
					gf.OutputPPT.Init();
					gf.ExternalPPT.Init();
					gf.SetPatternPeriod();
					result = true;
				}
			}
			return result;
		}
		public static void LoadEulaText()
		{
			gf.EULA = "EasiSlides Software\n\nIMPORTANT: This software end user licence agreement ('EULA') is a legal agreement between you and EasiSlides. Read it carefully before completing the installation process and using the software. It provides a licence to use the software. By installing and using the software, you are confirming your acceptance of the software and agreeing to become bound by the terms of this agreement. If you do not agree with the terms of this licence you must remove EasiSlides Software files from your storage devices and cease to use the product.\n\nAll copyrights to 'EasiSlides Software', hereafter shall be referred to as 'the software', are exclusively owned by EasiSlides. Your licence confers no title or ownership in the software and should not be construed as a sale of any right in the software.\n\nYou MUST NOT use this software for purposes which are unlawful, including, but not limited to, the transmission of obscene or offensive content, or contents which may harass or cause distress to any person.\n\nYou may use this software for any length of time.\n\nYou are hereby licenced to make any number of backup copies of this software and documentation. You can give the copy of the software to anyone or distribute the software provided you abide by the following Licence restrictions:\n(a) You may not reproduce or distribute the software for the purpose of promoting other non-EasiSlides products or organisations unless specific permission to do so have been obtained from the EasiSlides Copyright holder.\n(b) You may not alter, merge, modify, adapt or translate the software, or decompile, reverse engineer, disassemble, or otherwise reduce the Software to a human-perceivable form.\n(c) You may not rent, lease, or sublicence the Software.\n(d) Where the software is placed on a network for distribution, you must place alongside the distributed software a fully functional and visible hyperlink to the official EasiSlides website at http://www.EasiSlides.com.\n(e) No fee is charged for the software.\n\nEASISLIDES SOFTWARE IS DISTRIBUTED 'AS IS'. NO WARRANTY OF ANY KIND IS EXPRESSED OR IMPLIED. YOU USE IT AT YOUR OWN RISK. EASISLIDES WILL NOT BE LIABLE FOR DATA LOSS, DAMAGES, LOSS OF PROFITS OR ANY OTHER KIND OF LOSS WHILE USING OR MISUSING THIS SOFTWARE.\n\nThis EULA  shall be governed by and construed in accordance with the laws of Northern Ireland. Any dispute arising under this EULA shall be subject to the exclusive jurisdiction of the courts of Northern Ireland.\n\nCopyright © 2007 EasiSlides, All rights reserved.\nInternet:  http://www.EasiSlides.com\n";
		}
		public static void ValidateID()
		{
			gf.SystemID = gf.GetRegValue("config", "ID", "");
			if (gf.SystemID.Length < 12)
			{
				gf.SystemID = gf.Right(Guid.NewGuid().ToString(), 12);
				gf.SaveRegValue("config", "ID", gf.SystemID);
			}
			else
			{
				if (gf.SystemID.Length > 12)
				{
					gf.SystemID = gf.Left(gf.SystemID, 12);
					gf.SaveRegValue("config", "ID", gf.SystemID);
				}
			}
		}
		public static string GetUniqueID()
		{
			return gf.Right(Guid.NewGuid().ToString(), 6);
		}
		public static void SetPatternPeriod()
		{
			TimeSpan timeSpan = DateTime.Now.Subtract(gf.PerformanceStartTime);
			if (timeSpan.TotalSeconds < 12.0)
			{
				gf.PatternTimerPeriod = 40;
			}
			else
			{
				if (timeSpan.TotalSeconds < 25.0)
				{
					gf.PatternTimerPeriod = 80;
				}
				else
				{
					gf.PatternTimerPeriod = 200;
				}
			}
		}
		public static DataSet GetDataSet1(string DBConnectString, string SqlString)
		{
			DataSet result;
			try
			{
				OleDbConnection selectConnection = new OleDbConnection(DBConnectString);
				OleDbDataAdapter oleDbDataAdapter = new OleDbDataAdapter(SqlString, selectConnection);
				DataSet dataSet = new DataSet();
				oleDbDataAdapter.Fill(dataSet);
				result = dataSet;
			}
			catch
			{
				result = null;
			}
			return result;
		}
		public static int InsertItemIntoDatabase(string InConnectString, gf.SongSettings InItem)
		{
			return gf.InsertItemIntoDatabase(InConnectString, InItem.Title, InItem.Title2, InItem.SongNumber, InItem.FolderNo, InItem.CompleteLyrics, InItem.SongSequence, InItem.Writer, InItem.Copyright, InItem.Capo, InItem.Timing, InItem.MusicKey, InItem.Notations, InItem.Category, InItem.Show_LicAdminInfo1, InItem.Show_LicAdminInfo2, InItem.Book_Reference, InItem.User_Reference, InItem.Settings, InItem.Format.FormatString);
		}
		public static int InsertItemIntoDatabase(string InConnectString, object Title_1, object Title_2, object song_number, int FolderNo, object Lyrics, object Sequence, object writer, object copyright, object capo, object Timing, object Key, object msc, object CATEGORY, object LICENCE_ADMIN1, object LICENCE_ADMIN2, object BOOK_REFERENCE, object USER_REFERENCE, object Settings, object FormatData)
		{
			string title_ = Title_1.ToString();
			string title_2 = Title_2.ToString();
			int song_number2 = gf.StringToInt(song_number.ToString());
			string lyrics = Lyrics.ToString();
			string sequence = Sequence.ToString();
			string writer2 = writer.ToString();
			string copyright2 = copyright.ToString();
			int capo2 = gf.StringToInt(capo.ToString(), true);
			string timing = Timing.ToString();
			string inKey = Key.ToString();
			string msc2 = msc.ToString();
			string cATEGORY = CATEGORY.ToString();
			string lICENCE_ADMIN = LICENCE_ADMIN1.ToString();
			string lICENCE_ADMIN2 = LICENCE_ADMIN2.ToString();
			string bOOK_REFERENCE = BOOK_REFERENCE.ToString();
			string uSER_REFERENCE = USER_REFERENCE.ToString();
			string sETTINGS = Settings.ToString();
			string fORMATDATA = FormatData.ToString();
			return gf.InsertItemIntoDatabase(InConnectString, title_, title_2, song_number2, FolderNo, lyrics, sequence, writer2, copyright2, capo2, timing, inKey, msc2, cATEGORY, lICENCE_ADMIN, lICENCE_ADMIN2, bOOK_REFERENCE, uSER_REFERENCE, sETTINGS, fORMATDATA);
		}
		public static int InsertItemIntoDatabase(string InConnectString, string Title_1, string Title_2, int song_number, int FolderNo, string Lyrics, string Sequence, string writer, string copyright, int capo, string Timing, string InKey, string msc, string CATEGORY, string LICENCE_ADMIN1, string LICENCE_ADMIN2, string BOOK_REFERENCE, string USER_REFERENCE, string SETTINGS, string FORMATDATA)
		{
			Title_1 = gf.Left(Title_1, 100);
			Title_2 = gf.Left(Title_2, 100);
			Sequence = gf.Left(Sequence, 100);
			writer = gf.Left(writer, 100);
			copyright = gf.Left(copyright, 100);
			Timing = gf.Left(Timing, 50);
			InKey = gf.Left(InKey, 20);
			LICENCE_ADMIN1 = gf.Left(LICENCE_ADMIN1, 50);
			LICENCE_ADMIN2 = gf.Left(LICENCE_ADMIN2, 50);
			BOOK_REFERENCE = gf.Left(BOOK_REFERENCE, 50);
			string value = gf.CJK_WordCount(Title_1);
			string value2 = gf.CJK_StrokeCount(Title_1);
			Recordset tableRecordSet = gf.GetTableRecordSet(InConnectString, "SONG");
			int result;
			if (tableRecordSet != null)
			{
				try
				{
					tableRecordSet.AddNew();
					tableRecordSet.Fields["Title_1"].Value = Title_1;
					tableRecordSet.Fields["Title_2"].Value = Title_2;
					tableRecordSet.Fields["song_number"].Value = song_number;
					tableRecordSet.Fields["FolderNo"].Value = FolderNo;
					tableRecordSet.Fields["Lyrics"].Value = Lyrics;
					tableRecordSet.Fields["Sequence"].Value = Sequence;
					tableRecordSet.Fields["writer"].Value = writer;
					tableRecordSet.Fields["copyright"].Value = copyright;
					tableRecordSet.Fields["CJK_WordCount"].Value = value;
					tableRecordSet.Fields["CJK_StrokeCount"].Value = value2;
					tableRecordSet.Fields["capo"].Value = capo;
					tableRecordSet.Fields["Timing"].Value = Timing;
					tableRecordSet.Fields["Key"].Value = InKey;
					tableRecordSet.Fields["msc"].Value = msc;
					tableRecordSet.Fields["CATEGORY"].Value = CATEGORY;
					tableRecordSet.Fields["LICENCE_ADMIN1"].Value = LICENCE_ADMIN1;
					tableRecordSet.Fields["LICENCE_ADMIN2"].Value = LICENCE_ADMIN2;
					tableRecordSet.Fields["BOOK_REFERENCE"].Value = BOOK_REFERENCE;
					tableRecordSet.Fields["USER_REFERENCE"].Value = USER_REFERENCE;
					tableRecordSet.Fields["SETTINGS"].Value = SETTINGS;
					tableRecordSet.Fields["FORMATDATA"].Value = FORMATDATA;
					tableRecordSet.Fields["LastModified"].Value = DateTime.Now.Date;
					tableRecordSet.Update(1, false);
					Array lastModified = tableRecordSet.LastModified;
                    tableRecordSet.set_Bookmark(ref lastModified);
					result = gf.ObjToInt(tableRecordSet.Fields["SongID"].Value);
					return result;
				}
				catch
				{
					MessageBox.Show("Error encountered whilst adding item to database - item NOT added");
				}
			}
			result = 0;
			return result;
		}
		public static int OldInsertADOItemIntoDatabase(string Title_1, string Title_2, int song_number, int FolderNo, string Lyrics, string Sequence, string writer, string copyright, int capo, string Timing, string InKey, string msc, string CATEGORY, string LICENCE_ADMIN1, string LICENCE_ADMIN2, string BOOK_REFERENCE, string USER_REFERENCE, string SETTINGS, string FORMATDATA)
		{
			int result = 0;
			Title_1 = gf.Left(Title_1, 100);
			Title_2 = gf.Left(Title_2, 100);
			Sequence = gf.Left(Sequence, 100);
			writer = gf.Left(writer, 100);
			copyright = gf.Left(copyright, 100);
			Timing = gf.Left(Timing, 50);
			InKey = gf.Left(InKey, 20);
			LICENCE_ADMIN1 = gf.Left(LICENCE_ADMIN1, 50);
			LICENCE_ADMIN2 = gf.Left(LICENCE_ADMIN2, 50);
			BOOK_REFERENCE = gf.Left(BOOK_REFERENCE, 50);
			string value = gf.CJK_WordCount(Title_1);
			string value2 = gf.CJK_StrokeCount(Title_1);
			OleDbConnection oleDbConnection = new OleDbConnection(gf.ConnectStringMainDB);
			oleDbConnection.Open();
			try
			{
				string text = "Insert into SONG (Title_1,Title_2,song_number,FolderNo,Lyrics,Sequence,writer,copyright,CJK_WordCount,CJK_StrokeCount,capo,Timing,[Key],msc,CATEGORY,LICENCE_ADMIN1,LICENCE_ADMIN2,BOOK_REFERENCE,USER_REFERENCE,SETTINGS,FORMATDATA,LastModified) Values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
				OleDbCommand oleDbCommand = new OleDbCommand(text, oleDbConnection);
				oleDbCommand.CommandText = text;
				oleDbCommand.Parameters.AddWithValue("@Title_1", Title_1);
				oleDbCommand.Parameters.AddWithValue("@Title_2", Title_2);
				oleDbCommand.Parameters.AddWithValue("@song_number", song_number);
				oleDbCommand.Parameters.AddWithValue("@FolderNo", FolderNo);
				oleDbCommand.Parameters.AddWithValue("@Lyrics", Lyrics);
				oleDbCommand.Parameters.AddWithValue("@Sequence", Sequence);
				oleDbCommand.Parameters.AddWithValue("@writer", writer);
				oleDbCommand.Parameters.AddWithValue("@copyright", copyright);
				oleDbCommand.Parameters.AddWithValue("@CJK_WordCount", value);
				oleDbCommand.Parameters.AddWithValue("@CJK_StrokeCount", value2);
				oleDbCommand.Parameters.AddWithValue("@capo", capo);
				oleDbCommand.Parameters.AddWithValue("@Timing", Timing);
				oleDbCommand.Parameters.AddWithValue("@Key", InKey);
				oleDbCommand.Parameters.AddWithValue("@msc", msc);
				oleDbCommand.Parameters.AddWithValue("@CATEGORY", CATEGORY);
				oleDbCommand.Parameters.AddWithValue("@LICENCE_ADMIN1", LICENCE_ADMIN1);
				oleDbCommand.Parameters.AddWithValue("@LICENCE_ADMIN2", LICENCE_ADMIN2);
				oleDbCommand.Parameters.AddWithValue("@BOOK_REFERENCE", BOOK_REFERENCE);
				oleDbCommand.Parameters.AddWithValue("@USER_REFERENCE", USER_REFERENCE);
				oleDbCommand.Parameters.AddWithValue("@SETTINGS", SETTINGS);
				oleDbCommand.Parameters.AddWithValue("@FORMATDATA", FORMATDATA);
				oleDbCommand.Parameters.AddWithValue("@LastModified", DateTime.Now.Date);
				oleDbCommand.ExecuteNonQuery();
				text = "Select @@IDENTITY As TheNewId";
				int num = (int)new OleDbCommand(text, oleDbConnection)
				{
					CommandText = text
				}.ExecuteScalar();
				if (num > 0)
				{
					result = num;
				}
			}
			catch
			{
				MessageBox.Show("Error encountered whilst adding item to database - item NOT added");
			}
			finally
			{
				if (oleDbConnection.State == ConnectionState.Open)
				{
					oleDbConnection.Close();
				}
			}
			return result;
		}
		public static bool UpdateDatabaseItem(string InConnectString, gf.SongSettings InItem, int SongID)
		{
			return gf.UpdateDatabaseItem(InConnectString, SongID, InItem.Title, InItem.Title2, InItem.SongNumber, InItem.FolderNo, InItem.CompleteLyrics, InItem.SongSequence, InItem.Writer, InItem.Copyright, InItem.Capo, InItem.Timing, InItem.MusicKey, InItem.Notations, InItem.Category, InItem.Show_LicAdminInfo1, InItem.Show_LicAdminInfo2, InItem.Book_Reference, InItem.User_Reference, InItem.Settings, InItem.Format.FormatString);
		}
		public static bool UpdateDatabaseItem(string InConnectString, int SongID, string Title_1, string Title_2, int song_number, int FolderNo, string Lyrics, string Sequence, string writer, string copyright, int capo, string Timing, string InKey, string msc, string CATEGORY, string LICENCE_ADMIN1, string LICENCE_ADMIN2, string BOOK_REFERENCE, string USER_REFERENCE, string SETTINGS, string FORMATDATA)
		{
			bool result = false;
			Title_1 = gf.Left(Title_1, 100);
			Title_2 = gf.Left(Title_2, 100);
			Sequence = gf.Left(Sequence, 100);
			writer = gf.Left(writer, 100);
			copyright = gf.Left(copyright, 100);
			Timing = gf.Left(Timing, 50);
			InKey = gf.Left(InKey, 20);
			LICENCE_ADMIN1 = gf.Left(LICENCE_ADMIN1, 50);
			LICENCE_ADMIN2 = gf.Left(LICENCE_ADMIN2, 50);
			BOOK_REFERENCE = gf.Left(BOOK_REFERENCE, 50);
			string value = gf.CJK_WordCount(Title_1);
			string value2 = gf.CJK_StrokeCount(Title_1);
			try
			{
				OleDbConnection oleDbConnection = new OleDbConnection(gf.ConnectStringMainDB);
				oleDbConnection.Open();
				try
				{
					string text = "Update SONG SET Title_1 =@Title_1,Title_2 =@Title_2,song_number =@song_number,FolderNo =@FolderNo,Lyrics =@Lyrics,Sequence =@Sequence,writer =@writer,copyright =@copyright,CJK_WordCount =@CJK_WordCount,CJK_StrokeCount =@CJK_StrokeCount,capo =@capo,Timing =@Timing,[Key] =@Key,msc =@msc,CATEGORY =@CATEGORY,LICENCE_ADMIN1 =@LICENCE_ADMIN1,LICENCE_ADMIN2 =@LICENCE_ADMIN2,BOOK_REFERENCE =@BOOK_REFERENCE,USER_REFERENCE =@USER_REFERENCE,SETTINGS =@SETTINGS,FORMATDATA =@FORMATDATA,LastModified =@LastModified where songid=" + SongID.ToString();
					OleDbCommand oleDbCommand = new OleDbCommand(text, oleDbConnection);
					oleDbCommand.CommandText = text;
					oleDbCommand.Parameters.AddWithValue("@Title_1", Title_1);
					oleDbCommand.Parameters.AddWithValue("@Title_2", Title_2);
					oleDbCommand.Parameters.AddWithValue("@song_number", song_number);
					oleDbCommand.Parameters.AddWithValue("@FolderNo", FolderNo);
					oleDbCommand.Parameters.AddWithValue("@Lyrics", Lyrics);
					oleDbCommand.Parameters.AddWithValue("@Sequence", Sequence);
					oleDbCommand.Parameters.AddWithValue("@writer", writer);
					oleDbCommand.Parameters.AddWithValue("@copyright", copyright);
					oleDbCommand.Parameters.AddWithValue("@CJK_WordCount", value);
					oleDbCommand.Parameters.AddWithValue("@CJK_StrokeCount", value2);
					oleDbCommand.Parameters.AddWithValue("@capo", capo);
					oleDbCommand.Parameters.AddWithValue("@Timing", Timing);
					oleDbCommand.Parameters.AddWithValue("@Key", InKey);
					oleDbCommand.Parameters.AddWithValue("@msc", msc);
					oleDbCommand.Parameters.AddWithValue("@CATEGORY", CATEGORY);
					oleDbCommand.Parameters.AddWithValue("@LICENCE_ADMIN1", LICENCE_ADMIN1);
					oleDbCommand.Parameters.AddWithValue("@LICENCE_ADMIN2", LICENCE_ADMIN2);
					oleDbCommand.Parameters.AddWithValue("@BOOK_REFERENCE", BOOK_REFERENCE);
					oleDbCommand.Parameters.AddWithValue("@USER_REFERENCE", USER_REFERENCE);
					oleDbCommand.Parameters.AddWithValue("@SETTINGS", SETTINGS);
					oleDbCommand.Parameters.AddWithValue("@FORMATDATA", FORMATDATA);
					oleDbCommand.Parameters.AddWithValue("@LastModified", DateTime.Now.Date);
					oleDbCommand.ExecuteNonQuery();
					oleDbConnection.Close();
					result = true;
				}
				catch (Exception ex)
				{
					MessageBox.Show("Error when writing to Database: \n" + ex.ToString());
				}
				finally
				{
					if (oleDbConnection.State == ConnectionState.Open)
					{
						oleDbConnection.Close();
					}
				}
			}
			catch (Exception ex)
			{
				MessageBox.Show("Error when writing to Database: \n" + ex.ToString());
			}
			return result;
		}
		public static void AssignDropDownItem(ref ToolStripDropDownButton SelectedBtn, string SelectedMenuItemName, ToolStripMenuItem InMenuItem1, ToolStripMenuItem InMenuItem2)
		{
			string tag;
			string text;
			if (SelectedMenuItemName == InMenuItem2.Name)
			{
				SelectedBtn.Image = InMenuItem2.Image;
				tag = (string)InMenuItem2.Tag;
				text = InMenuItem2.Text;
			}
			else
			{
				SelectedBtn.Image = InMenuItem1.Image;
				tag = (string)InMenuItem1.Tag;
				text = InMenuItem1.Text;
			}
			SelectedBtn.Tag = tag;
			SelectedBtn.ToolTipText = text;
		}
		public static void AssignDropDownItem(ref ToolStripDropDownButton SelectedBtn, string SelectedMenuItemName, ToolStripMenuItem InMenuItem1, ToolStripMenuItem InMenuItem2, ToolStripMenuItem InMenuItem3)
		{
			string tag;
			string text;
			if (SelectedMenuItemName == InMenuItem2.Name)
			{
				SelectedBtn.Image = InMenuItem2.Image;
				tag = (string)InMenuItem2.Tag;
				text = InMenuItem2.Text;
			}
			else
			{
				if (SelectedMenuItemName == InMenuItem3.Name)
				{
					SelectedBtn.Image = InMenuItem3.Image;
					tag = (string)InMenuItem3.Tag;
					text = InMenuItem3.Text;
				}
				else
				{
					SelectedBtn.Image = InMenuItem1.Image;
					tag = (string)InMenuItem1.Tag;
					text = InMenuItem1.Text;
				}
			}
			SelectedBtn.Tag = tag;
			SelectedBtn.ToolTipText = text;
		}
		public static void AssignDropDownItem(ref ToolStripDropDownButton SelectedBtn, string SelectedMenuItemName, ToolStripMenuItem InMenuItem1, ToolStripMenuItem InMenuItem2, ToolStripMenuItem InMenuItem3, ToolStripMenuItem InMenuItem4)
		{
			string tag;
			string text;
			if (SelectedMenuItemName == InMenuItem2.Name)
			{
				SelectedBtn.Image = InMenuItem2.Image;
				tag = (string)InMenuItem2.Tag;
				text = InMenuItem2.Text;
			}
			else
			{
				if (SelectedMenuItemName == InMenuItem3.Name)
				{
					SelectedBtn.Image = InMenuItem3.Image;
					tag = (string)InMenuItem3.Tag;
					text = InMenuItem3.Text;
				}
				else
				{
					if (SelectedMenuItemName == InMenuItem4.Name)
					{
						SelectedBtn.Image = InMenuItem4.Image;
						tag = (string)InMenuItem4.Tag;
						text = InMenuItem4.Text;
					}
					else
					{
						SelectedBtn.Image = InMenuItem1.Image;
						tag = (string)InMenuItem1.Tag;
						text = InMenuItem1.Text;
					}
				}
			}
			SelectedBtn.Tag = tag;
			SelectedBtn.ToolTipText = text;
		}
		public static void AssignDropDownItem(ref ToolStripDropDownButton SelectedBtn, string SelectedMenuItemName, ToolStripMenuItem InMenuItem1, ToolStripMenuItem InMenuItem2, ToolStripMenuItem InMenuItem3, ToolStripMenuItem InMenuItem4, ToolStripMenuItem InMenuItem5)
		{
			string tag;
			string text;
			if (SelectedMenuItemName == InMenuItem2.Name)
			{
				SelectedBtn.Image = InMenuItem2.Image;
				tag = (string)InMenuItem2.Tag;
				text = InMenuItem2.Text;
			}
			else
			{
				if (SelectedMenuItemName == InMenuItem3.Name)
				{
					SelectedBtn.Image = InMenuItem3.Image;
					tag = (string)InMenuItem3.Tag;
					text = InMenuItem3.Text;
				}
				else
				{
					if (SelectedMenuItemName == InMenuItem4.Name)
					{
						SelectedBtn.Image = InMenuItem4.Image;
						tag = (string)InMenuItem4.Tag;
						text = InMenuItem4.Text;
					}
					else
					{
						if (SelectedMenuItemName == InMenuItem5.Name)
						{
							SelectedBtn.Image = InMenuItem5.Image;
							tag = (string)InMenuItem5.Tag;
							text = InMenuItem5.Text;
						}
						else
						{
							SelectedBtn.Image = InMenuItem1.Image;
							tag = (string)InMenuItem1.Tag;
							text = InMenuItem1.Text;
						}
					}
				}
			}
			SelectedBtn.Tag = tag;
			SelectedBtn.ToolTipText = text;
		}
		public static Color SelectNewColour(Color CurColour)
		{
			Color result = CurColour;
			gf.SelectColor(ref result);
			return result;
		}
		public static bool SelectColorFromBtn(ref Button InBtn, ref Color ColourSymbol)
		{
			Color foreColor = InBtn.ForeColor;
			bool result;
			if (gf.SelectColor(ref foreColor))
			{
				InBtn.ForeColor = foreColor;
				ColourSymbol = foreColor;
				result = true;
			}
			else
			{
				result = false;
			}
			return result;
		}
		public static bool SelectColorFromBtn(ref ToolStripButton InBtn, ref Color ColourSymbol)
		{
			Color foreColor = InBtn.ForeColor;
			bool result;
			if (gf.SelectColor(ref foreColor))
			{
				InBtn.ForeColor = foreColor;
				ColourSymbol = foreColor;
				result = true;
			}
			else
			{
				result = false;
			}
			return result;
		}
		public static bool SelectColor(ref Color InColour)
		{
			ColorDialog colorDialog = new ColorDialog();
			colorDialog.Color = InColour;
			bool result;
			if (colorDialog.ShowDialog() == DialogResult.OK)
			{
				InColour = colorDialog.Color;
				result = true;
			}
			else
			{
				result = false;
			}
			return result;
		}
		public static bool SelectBackgroundColours(ref ToolStripButton InBtn, ref Color InColour1, ref Color InColour2, ref int InStyle, bool IsDefault)
		{
			gf.ChangedBackColour1 = InColour1;
			gf.ChangedBackColour2 = InColour2;
			gf.ChangedBackStyle = InStyle;
			gf.ChangedIsDefault = IsDefault;
			FrmBackground frmBackground = new FrmBackground();
			bool result;
			if (frmBackground.ShowDialog() == DialogResult.OK)
			{
				InColour1 = gf.ChangedBackColour1;
				InColour2 = gf.ChangedBackColour2;
				InStyle = gf.ChangedBackStyle;
				InBtn.ForeColor = InColour1;
				result = true;
			}
			else
			{
				result = false;
			}
			return result;
		}
		public static void BuildFontsList(ref ToolStripComboBox InTSComboBox)
		{
			if (gf.FontsListMaxIndex < 0)
			{
				InstalledFontCollection installedFontCollection = new InstalledFontCollection();
				FontFamily[] families = installedFontCollection.Families;
				gf.FontsListMaxIndex = -1;
				FontFamily[] array = families;
				for (int i = 0; i < array.Length; i++)
				{
					FontFamily fontFamily = array[i];
					gf.FontsList[++gf.FontsListMaxIndex] = fontFamily.Name;
				}
			}
			if (gf.FontsListMaxIndex >= 0)
			{
				InTSComboBox.Items.Clear();
				InTSComboBox.Sorted = false;
				for (int j = 0; j <= gf.FontsListMaxIndex; j++)
				{
					InTSComboBox.Items.Add(gf.FontsList[j]);
				}
				InTSComboBox.Sorted = true;
				InTSComboBox.SelectedIndex = 0;
			}
		}
		public static void BuildFontSizeList(ref ToolStripComboBox InCombo)
		{
			InCombo.Items.Clear();
			InCombo.Items.Add("8");
			InCombo.Items.Add("9");
			InCombo.Items.Add("10");
			InCombo.Items.Add("11");
			InCombo.Items.Add("12");
			InCombo.Items.Add("13");
			InCombo.Items.Add("14");
			InCombo.Items.Add("15");
			InCombo.Items.Add("16");
			InCombo.Items.Add("17");
			InCombo.Items.Add("18");
			InCombo.Items.Add("19");
			InCombo.Items.Add("20");
		}
		public static string GetDisplayNameOnly(ref string InFileName, bool UpdateByRef)
		{
			return gf.GetDisplayNameOnly(ref InFileName, UpdateByRef, false);
		}
		public static string GetDisplayNameOnly(ref string InFileName, bool UpdateByRef, bool KeepExt)
		{
			string result;
			if (InFileName == null | InFileName == "")
			{
				result = "";
			}
			else
			{
				string text = "";
				try
				{
					if (KeepExt)
					{
						text = Path.GetFileName(InFileName);
					}
					else
					{
						text = Path.GetFileNameWithoutExtension(InFileName);
					}
					if (UpdateByRef)
					{
						InFileName = text;
					}
				}
				catch
				{
				}
				result = text;
			}
			return result;
		}
		public static bool MakeDir(string sDir)
		{
			bool result;
			try
			{
				Directory.CreateDirectory(sDir);
				result = true;
			}
			catch
			{
				if (Directory.Exists(sDir))
				{
					result = true;
				}
				else
				{
					result = false;
				}
			}
			return result;
		}
		public static bool CreateNewFile(string FILE_NAME)
		{
			return gf.CreateNewFile(FILE_NAME, gf.FileContentsType.DoubleByte);
		}
		public static bool CreateNewFile(string FILE_NAME, gf.FileContentsType Mode)
		{
			return gf.CreateNewFile(FILE_NAME, Mode, "");
		}
		public static bool CreateNewFile(string FILE_NAME, gf.FileContentsType Mode, string Contents)
		{
			bool result;
			try
			{
				if (Mode == gf.FileContentsType.DoubleByte)
				{
					FileStream fileStream = new FileStream(FILE_NAME, FileMode.Create);
					BinaryWriter binaryWriter = new BinaryWriter(fileStream);
					binaryWriter.Write(255);
					binaryWriter.Write(254);
					gf.WriteStringToBinaryFile(ref binaryWriter, Contents);
					binaryWriter.Close();
					fileStream.Close();
					result = true;
					return result;
				}
				StreamWriter streamWriter = new StreamWriter(FILE_NAME, false, Encoding.Default);
				streamWriter.Write((Mode == gf.FileContentsType.Ascii_Rtf) ? gf.UnicodeToAscii_RTF(Contents) : gf.UnicodeToAscii_HTML(Contents));
				streamWriter.Flush();
				streamWriter.Close();
			}
			catch
			{
			}
			result = false;
			return result;
		}
		public static void SaveRegValue(string Section, string Name, string Value)
		{
			try
			{
				using (RegistryKey registryKey = Registry.CurrentUser.CreateSubKey("Software\\EasiSlides\\" + Section))
				{
					registryKey.SetValue(Name, Value, RegistryValueKind.String);
				}
			}
			catch
			{
			}
		}
		public static void SaveRegValue(string Section, string Name, int Value)
		{
			try
			{
				using (RegistryKey registryKey = Registry.CurrentUser.CreateSubKey("Software\\EasiSlides\\" + Section))
				{
					registryKey.SetValue(Name, Value, RegistryValueKind.DWord);
				}
			}
			catch
			{
			}
		}
		public static void SaveRegValue(string Section, string Name, long Value)
		{
			try
			{
				using (RegistryKey registryKey = Registry.CurrentUser.CreateSubKey("Software\\EasiSlides\\" + Section))
				{
					registryKey.SetValue(Name, Value, RegistryValueKind.QWord);
				}
			}
			catch
			{
			}
		}
		public static string GetRegValue(string Section, string Name, string defaultValue)
		{
            object regValue = GetRegValueObj(Section, Name, defaultValue);
			string result;
			if (regValue == null)
			{
				result = defaultValue;
			}
			else
			{
				result = gf.ObjToString(regValue);
			}
			return result;
		}
		public static int GetRegValue(string Section, string Name, int defaultValue)
		{
            object regValue = GetRegValueObj(Section, Name, defaultValue);
            int result;
            if (regValue == null)
            {
                result = defaultValue;
            }
            else
            {
                result = gf.ObjToInt(regValue);
            }
			return result;
		}
		public static object GetRegValueObj(string Section, string Name, object defaultValue)
		{
			object result;
			try
			{
				using (RegistryKey registryKey = Registry.CurrentUser.CreateSubKey("Software\\EasiSlides\\" + Section))
				{
					result = registryKey.GetValue(Name, defaultValue);
				}
			}
			catch
			{
				result = null;
			}
			return result;
		}
		public static void DeleletRegKey(string Section, string Name)
		{
			try
			{
				RegistryKey registryKey = Registry.CurrentUser.OpenSubKey("Software\\EasiSlides\\" + Section, true);
				registryKey.DeleteValue(Name);
				registryKey.Close();
			}
			catch
			{
			}
		}
		public static string Trim(string InString)
		{
			string result;
			try
			{
				result = InString.Trim();
			}
			catch
			{
				result = "";
			}
			return result;
		}
		public static string TrimEnd(string InString)
		{
			string result;
			try
			{
				result = InString.TrimEnd(new char[]
				{
					'\n',
					'\r'
				});
			}
			catch
			{
				result = "";
			}
			return result;
		}
		public static string TrimStart(string InString)
		{
			string result;
			try
			{
				result = InString.TrimStart(new char[]
				{
					'\n',
					'\r'
				});
			}
			catch
			{
				result = "";
			}
			return result;
		}
		public static bool LoadUnicodeStrokeCount()
		{
			string text = "";
			bool result;
			if (gf.LoadFileContents(Application.StartupPath + "\\Sys\\strokecount.dat", ref text))
			{
				int i = 1;
				int num = text.Length - 2;
				while (i <= num - 2)
				{
					int num2 = gf.ObjToInt(text.Substring(i, 2));
					if (num2 > 0)
					{
						int num3 = (int)text[i - 1];
						if (num3 < 0)
						{
							num3 += 65536;
						}
						if (num3 >= 0)
						{
							gf.StrokeCount[num3] = num2;
						}
					}
					i += 3;
				}
				result = true;
			}
			else
			{
				gf.MessageOverSplashScreen("The EasiSlides system file strokecount.dat is missing. Please re-install EasiSlides Software.");
				result = false;
			}
			return result;
		}
		public static bool LoadFileContents(string InFileName, ref string InString)
		{
			InString = "";
			bool result;
			if (File.Exists(InFileName))
			{
				StreamReader streamReader = new StreamReader(InFileName, true);
				InString = streamReader.ReadToEnd();
				streamReader.Close();
				result = true;
			}
			else
			{
				result = false;
			}
			return result;
		}
		public static bool ValidateRootFolder()
		{
			if (gf.Right(gf.RootEasiSlidesDir, 1) != "\\")
			{
				gf.RootEasiSlidesDir += "\\";
			}
			bool result;
			if (Directory.Exists(gf.RootEasiSlidesDir))
			{
				result = true;
			}
			else
			{
                //try
                //{
                //    if (gf.ApplicationFirstRun)
                //    {
                //        if (gf.MakeDir(gf.RootEasiSlidesDir))
                //        {
                //            gf.RestoreSongsDatabase = true;
                //            gf.RestoreBackgroundImages();
                //            result = true;
                //            return result;
                //        }
                //        gf.MessageOverSplashScreen("Error encountered whilst creating the EasiSlides Working folder: " + gf.RootEasiSlidesDir + ". Make sure have write access to the area and try again");
                //        result = false;
                //        return result;
                //    }
                //}
                //catch
                //{
                //}
				gf.SplashScreenBack = true;
				FrmGetWorkingFolder frmGetWorkingFolder = new FrmGetWorkingFolder();
				if (frmGetWorkingFolder.ShowDialog() == DialogResult.OK)
				{
					gf.RestoreBackgroundImages();
					gf.SplashScreenBack = false;
					result = true;
				}
				else
				{
					gf.SplashScreenBack = false;
					result = false;
				}
			}
			return result;
		}
		public static string Left(string sString, int iLen)
		{
			string result;
			try
			{
				if (iLen <= 0 || sString.Length == 0)
				{
					result = "";
				}
				else
				{
					if (iLen < sString.Length)
					{
						result = sString.Substring(0, iLen);
					}
					else
					{
						result = sString;
					}
				}
			}
			catch
			{
				result = sString;
			}
			return result;
		}
		public static string Right(string sString, int iLen)
		{
			string result;
			try
			{
				if (iLen <= 0 || sString.Length == 0)
				{
					result = "";
				}
				else
				{
					if (iLen < sString.Length)
					{
						result = sString.Substring(sString.Length - iLen, iLen);
					}
					else
					{
						result = sString;
					}
				}
			}
			catch
			{
				result = sString;
			}
			return result;
		}
		public static string Mid(string sString, int Start)
		{
			return gf.Mid(sString, Start, -1);
		}
		public static string Mid(string sString, int Start, int iLen)
		{
			string result;
			try
			{
				if (iLen == 0 || sString.Length == 0)
				{
					result = "";
				}
				else
				{
					if (iLen < 0)
					{
						iLen = sString.Length - Start;
					}
					else
					{
						if (Start + iLen > sString.Length)
						{
							iLen = sString.Length - Start;
						}
					}
					result = sString.Substring(Start, iLen);
				}
			}
			catch
			{
				result = sString;
			}
			return result;
		}
		public static bool ValidateVer_3_4_Fields()
		{
			bool result;
			if (!gf.ValidateDB(gf.DatabaseType.Songs))
			{
				result = false;
			}
			else
			{
				bool flag = false;
				bool flag2 = false;
				bool flag3 = false;
				bool flag4 = false;
				bool flag5 = false;
				bool flag6 = false;
				bool flag7 = false;
				bool flag8 = false;
				bool flag9 = false;
				bool flag10 = false;
				bool flag11 = false;
				bool flag12 = false;
				bool flag13 = false;
				bool flag14 = false;
				bool flag15 = false;
				bool flag16 = false;
				bool flag17 = false;
				bool flag18 = false;
				int num = 0;
				int num2 = 0;
				int num3 = 0;
				bool flag19 = false;
				bool flag20 = false;
				bool flag21 = false;
				bool flag22 = false;
				OleDbConnection oleDbConnection = new OleDbConnection(gf.ConnectStringMainDB);
				try
				{
					oleDbConnection.Open();
					OleDbConnection arg_8B_0 = oleDbConnection;
					Guid arg_8B_1 = OleDbSchemaGuid.Columns;
					object[] array = new object[4];
					array[2] = "Folder";
					DataTable oleDbSchemaTable = arg_8B_0.GetOleDbSchemaTable(arg_8B_1, array);
					foreach (DataRow dataRow in oleDbSchemaTable.Rows)
					{
						string a = gf.ObjToString(dataRow["COLUMN_NAME"]).ToUpper();
						if (a != "")
						{
							if (a == "BIU0".ToUpper())
							{
								flag = true;
							}
							if (a == "BIU1".ToUpper())
							{
								flag2 = true;
							}
							if (a == "ColA".ToUpper())
							{
								flag3 = true;
							}
							if (a == "ColB".ToUpper())
							{
								flag4 = true;
							}
							if (a == "LMargin".ToUpper())
							{
								flag6 = true;
							}
							if (a == "RMargin".ToUpper())
							{
								flag7 = true;
							}
							if (a == "BMargin".ToUpper())
							{
								flag8 = true;
							}
							if (a == "BIUHeading".ToUpper())
							{
								flag9 = true;
							}
							if (a == "HeadingSize".ToUpper())
							{
								flag10 = true;
							}
							if (a == "HeadingOption".ToUpper())
							{
								flag11 = true;
							}
							if (a == "LineSpacing".ToUpper())
							{
								flag12 = true;
							}
							if (a == "LineSpacing2".ToUpper())
							{
								flag13 = true;
							}
							if (a == "PreChorusHeading".ToUpper())
							{
								flag5 = true;
							}
						}
					}
					if (!flag)
					{
						gf.CreateField(ref oleDbConnection, "Folder", "BIU0", 1);
					}
					if (!flag2)
					{
						gf.CreateField(ref oleDbConnection, "Folder", "BIU1", 1);
					}
					if (!flag3)
					{
						gf.CreateField(ref oleDbConnection, "Folder", "ColA", 0);
					}
					if (!flag4)
					{
						gf.CreateField(ref oleDbConnection, "Folder", "ColB", 0);
					}
					if (!flag6)
					{
						gf.CreateField(ref oleDbConnection, "Folder", "LMargin", 1);
					}
					if (!flag7)
					{
						gf.CreateField(ref oleDbConnection, "Folder", "RMargin", 1);
					}
					if (!flag8)
					{
						gf.CreateField(ref oleDbConnection, "Folder", "BMargin", 1);
					}
					if (!flag9)
					{
						gf.CreateField(ref oleDbConnection, "Folder", "BIUHeading", 1);
					}
					if (!flag10)
					{
						gf.CreateField(ref oleDbConnection, "Folder", "HeadingSize", 1);
					}
					if (!flag11)
					{
						gf.CreateField(ref oleDbConnection, "Folder", "HeadingOption", 1);
					}
					if (!flag12)
					{
						gf.CreateField(ref oleDbConnection, "Folder", "LineSpacing", 4);
					}
					if (!flag13)
					{
						gf.CreateField(ref oleDbConnection, "Folder", "LineSpacing2", 4);
					}
					if (!flag5)
					{
						gf.CreateField(ref oleDbConnection, "Folder", "PreChorusHeading", 0, 30);
					}
				}
				catch
				{
				}
				finally
				{
					if (oleDbConnection.State == ConnectionState.Open)
					{
						oleDbConnection.Close();
					}
				}
				try
				{
					oleDbConnection.Open();
					OleDbConnection arg_437_0 = oleDbConnection;
					Guid arg_437_1 = OleDbSchemaGuid.Columns;
					object[] array = new object[4];
					array[2] = "Song";
					DataTable oleDbSchemaTable = arg_437_0.GetOleDbSchemaTable(arg_437_1, array);
					foreach (DataRow dataRow in oleDbSchemaTable.Rows)
					{
						string a = gf.ObjToString(dataRow["COLUMN_NAME"]).ToUpper();
						if (a != "")
						{
							if (a == "CAPO".ToUpper())
							{
								flag14 = true;
							}
							if (a == "TIMING".ToUpper())
							{
								flag15 = true;
							}
							if (a == "SONG_NUMBER".ToUpper())
							{
								flag16 = true;
							}
							if (a == "BOOK_REFERENCE".ToUpper())
							{
								flag17 = true;
								num2 = gf.ObjToInt(dataRow["CHARACTER_MAXIMUM_LENGTH"]);
							}
							if (a == "USER_REFERENCE".ToUpper())
							{
								flag18 = true;
								num = gf.ObjToInt(dataRow["CHARACTER_MAXIMUM_LENGTH"]);
							}
							if (a == "LICENCE_ADMIN1".ToUpper())
							{
								flag19 = true;
							}
							if (a == "LICENCE_ADMIN2".ToUpper())
							{
								flag20 = true;
							}
							if (a == "SETTINGS".ToUpper())
							{
								flag21 = true;
							}
							if (a == "SEQUENCE".ToUpper())
							{
								num3 = gf.ObjToInt(dataRow["CHARACTER_MAXIMUM_LENGTH"]);
							}
							if (a == "FORMATDATA".ToUpper())
							{
								flag22 = true;
							}
						}
					}
					if (num2 > 1 && num2 < 100)
					{
						OleDbCommand oleDbCommand = new OleDbCommand("ALTER TABLE Song ALTER COLUMN BOOK_REFERENCE TEXT (100) ", oleDbConnection);
						oleDbCommand.ExecuteNonQuery();
					}
					if (num3 > 1 && num3 < 255)
					{
						OleDbCommand oleDbCommand = new OleDbCommand("ALTER TABLE Song ALTER COLUMN SEQUENCE TEXT (255) ", oleDbConnection);
						oleDbCommand.ExecuteNonQuery();
					}
					if (!flag14)
					{
						gf.CreateField(ref oleDbConnection, "Song", "CAPO", 1);
					}
					if (!flag15)
					{
						gf.CreateField(ref oleDbConnection, "Song", "TIMING", 0);
					}
					if (!flag16)
					{
						gf.CreateField(ref oleDbConnection, "Song", "SONG_NUMBER", 1);
					}
					if (!flag17)
					{
						gf.CreateField(ref oleDbConnection, "Song", "BOOK_REFERENCE", 0);
					}
					if (!flag18)
					{
						gf.CreateField(ref oleDbConnection, "Song", "USER_REFERENCE", 5);
					}
					else
					{
						if (num > 0)
						{
							OleDbCommand oleDbCommand = new OleDbCommand("ALTER TABLE Song ALTER COLUMN USER_REFERENCE MEMO ", oleDbConnection);
							oleDbCommand.ExecuteNonQuery();
						}
					}
					if (!flag19)
					{
						gf.CreateField(ref oleDbConnection, "Song", "LICENCE_ADMIN1", 0);
					}
					if (!flag20)
					{
						gf.CreateField(ref oleDbConnection, "Song", "LICENCE_ADMIN2", 0);
					}
					if (!flag21)
					{
						gf.CreateField(ref oleDbConnection, "Song", "SETTINGS", 5);
					}
					if (!flag22)
					{
						gf.CreateField(ref oleDbConnection, "Song", "FORMATDATA", 5);
					}
				}
				catch
				{
				}
				finally
				{
					if (oleDbConnection.State == ConnectionState.Open)
					{
						oleDbConnection.Close();
					}
				}
				try
				{
					oleDbConnection.Open();
					bool flag23 = false;
					string text = "LICENCE";
					DataTable oleDbSchemaTable = oleDbConnection.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, new object[]
					{
						null,
						null,
						text,
						"TABLE"
					});
					foreach (DataRow dataRow in oleDbSchemaTable.Rows)
					{
						if (gf.ObjToString(dataRow["TABLE_NAME"]).ToUpper() == text.ToUpper())
						{
							flag23 = true;
						}
					}
					if (!flag23)
					{
						OleDbCommand oleDbCommand = new OleDbCommand("CREATE TABLE " + text, oleDbConnection);
						oleDbCommand.ExecuteNonQuery();
						gf.CreateField(ref oleDbConnection, text, "ADMINISTRATOR", 0);
						gf.CreateField(ref oleDbConnection, text, "REF", 1);
					}
					gf.DropTable(ref oleDbConnection, "USAGE");
					gf.DropTable(ref oleDbConnection, "BIBLEFOLDER");
				}
				catch
				{
				}
				finally
				{
					if (oleDbConnection.State == ConnectionState.Open)
					{
						oleDbConnection.Close();
					}
				}
				if (!gf.ValidateDB(gf.DatabaseType.Usages))
				{
					result = false;
				}
				else
				{
					oleDbConnection = new OleDbConnection(gf.ConnectStringUsageDB);
					try
					{
						oleDbConnection.Open();
						bool flag23 = false;
						string text = "USAGE";
						DataTable oleDbSchemaTable = oleDbConnection.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, new object[]
						{
							null,
							null,
							text,
							"TABLE"
						});
						foreach (DataRow dataRow in oleDbSchemaTable.Rows)
						{
							if (gf.ObjToString(dataRow["TABLE_NAME"]).ToUpper() == text.ToUpper())
							{
								flag23 = true;
							}
						}
						if (!flag23)
						{
							Workspace workspace = gf.DAODBEngine_definst.Workspaces[0];
							Database database = workspace.OpenDatabase(oleDbConnection.DataSource, false, false, null);
							database.Execute("CREATE TABLE USAGE(REC_ID  autoincrement)", null);
							gf.CreateField(ref oleDbConnection, "USAGE", "WORSHIP_DATE", 2);
							gf.CreateField(ref oleDbConnection, "USAGE", "WORSHIP_LIST", 0);
							gf.CreateField(ref oleDbConnection, "USAGE", "SONG_TITLE", 0, 100);
							gf.CreateField(ref oleDbConnection, "USAGE", "SONG_NUMBER", 1);
							gf.CreateField(ref oleDbConnection, "USAGE", "SONG_ID", 0);
							gf.CreateField(ref oleDbConnection, "USAGE", "ADMIN_1", 0);
							gf.CreateField(ref oleDbConnection, "USAGE", "ADMIN_2", 0);
						}
						gf.DropTable(ref oleDbConnection, "SONG");
						gf.DropTable(ref oleDbConnection, "LICENCE");
						gf.DropTable(ref oleDbConnection, "FOLDER");
						gf.DropTable(ref oleDbConnection, "BIBLEFOLDER");
					}
					catch
					{
					}
					finally
					{
						if (oleDbConnection.State == ConnectionState.Open)
						{
							oleDbConnection.Close();
						}
					}
					if (!gf.ValidateDB(gf.DatabaseType.Bible))
					{
						result = false;
					}
					else
					{
						oleDbConnection = new OleDbConnection(gf.ConnectStringBibleDB);
						try
						{
							oleDbConnection.Open();
							bool flag23 = false;
							string text = "BIBLEFOLDER";
							DataTable oleDbSchemaTable = oleDbConnection.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, new object[]
							{
								null,
								null,
								text,
								"TABLE"
							});
							foreach (DataRow dataRow in oleDbSchemaTable.Rows)
							{
								if (gf.ObjToString(dataRow["TABLE_NAME"]).ToUpper() == text.ToUpper())
								{
									flag23 = true;
								}
							}
							if (!flag23)
							{
								OleDbCommand oleDbCommand = new OleDbCommand("CREATE TABLE " + text, oleDbConnection);
								oleDbCommand.ExecuteNonQuery();
								gf.CreateField(ref oleDbConnection, "BIBLEFOLDER", "NAME", 0, 100);
								gf.CreateField(ref oleDbConnection, "BIBLEFOLDER", "DESCRIPTION", 0, 100);
								gf.CreateField(ref oleDbConnection, "BIBLEFOLDER", "FILENAME", 0, 100);
								gf.CreateField(ref oleDbConnection, "BIBLEFOLDER", "COPYRIGHT", 0, 100);
								gf.CreateField(ref oleDbConnection, "BIBLEFOLDER", "SONGFOLDER", 1);
								gf.CreateField(ref oleDbConnection, "BIBLEFOLDER", "[SIZE]", 1);
								gf.CreateField(ref oleDbConnection, "BIBLEFOLDER", "DISPLAYORDER", 1);
							}
							gf.DropTable(ref oleDbConnection, "SONG");
							gf.DropTable(ref oleDbConnection, "LICENCE");
							gf.DropTable(ref oleDbConnection, "FOLDER");
							gf.DropTable(ref oleDbConnection, "USAGE");
						}
						catch
						{
						}
						finally
						{
							if (oleDbConnection.State == ConnectionState.Open)
							{
								oleDbConnection.Close();
							}
						}
						result = true;
					}
				}
			}
			return result;
		}
		public static void DropTable(ref OleDbConnection myConnection, string InTableName)
		{
			try
			{
				bool flag = false;
				DataTable oleDbSchemaTable = myConnection.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, new object[]
				{
					null,
					null,
					InTableName,
					"TABLE"
				});
				foreach (DataRow dataRow in oleDbSchemaTable.Rows)
				{
					if (InTableName.ToUpper() == gf.ObjToString(dataRow["TABLE_NAME"]).ToUpper())
					{
						flag = true;
					}
				}
				if (flag)
				{
					OleDbCommand oleDbCommand = new OleDbCommand("DROP TABLE " + InTableName, myConnection);
					oleDbCommand.ExecuteNonQuery();
				}
			}
			catch
			{
			}
		}
		public static void CreateField(ref OleDbConnection myConnection, string InTableName, string InFieldName, int InFieldType)
		{
			gf.CreateField(ref myConnection, InTableName, InFieldName, InFieldType, 50);
		}
		public static void CreateField(ref OleDbConnection myConnection, string InTableName, string InFieldName, int InFieldType, int InFieldSize)
		{
			string text = "";
			try
			{
				switch (InFieldType)
				{
				case 0:
					text = string.Concat(new string[]
					{
						"ALTER TABLE ",
						InTableName,
						" ADD COLUMN ",
						InFieldName,
						" TEXT(",
						gf.ObjToString(InFieldSize),
						") NULL "
					});
					break;
				case 1:
					text = string.Concat(new string[]
					{
						"ALTER TABLE ",
						InTableName,
						" ADD COLUMN ",
						InFieldName,
						" INT"
					});
					break;
				case 2:
					text = string.Concat(new string[]
					{
						"ALTER TABLE ",
						InTableName,
						" ADD COLUMN ",
						InFieldName,
						" DATE"
					});
					break;
				case 4:
					text = string.Concat(new string[]
					{
						"ALTER TABLE ",
						InTableName,
						" ADD COLUMN ",
						InFieldName,
						" FLOAT"
					});
					break;
				case 5:
					text = string.Concat(new string[]
					{
						"ALTER TABLE ",
						InTableName,
						" ADD COLUMN ",
						InFieldName,
						" MEMO"
					});
					break;
				}
				if (!(text == ""))
				{
					Workspace workspace = gf.DAODBEngine_definst.Workspaces[0];
					Database database = workspace.OpenDatabase(myConnection.DataSource, false, false, null);
					database.Execute(text, null);
					if (InFieldType == 0)
					{
						TableDef tableDef = database.TableDefs[InTableName];
						Field field = tableDef.Fields[InFieldName];
						field.AllowZeroLength = true;
						if (InFieldName.ToUpper() == "TIMING".ToUpper())
						{
							field = tableDef.Fields["MSC"];
							field.AllowZeroLength = true;
						}
					}
				}
			}
			catch
			{
			}
		}
		public static Database GetDaoDb(string ConnectString)
		{
			Database result;
			try
			{
				OleDbConnection oleDbConnection = new OleDbConnection(ConnectString);
				Workspace workspace = gf.DAODBEngine_definst.Workspaces[0];
				Database database = workspace.OpenDatabase(oleDbConnection.DataSource, false, false, null);
				result = database;
			}
			catch
			{
				result = null;
			}
			return result;
		}
		public static Recordset GetRecordSet(Database db, string FullSearchString)
		{
			Recordset result;
			try
			{
				Recordset recordset = db.OpenRecordset(FullSearchString, RecordsetTypeEnum.dbOpenDynaset, RecordsetOptionEnum.dbConsistent, LockTypeEnum.dbOptimistic);
				result = recordset;
			}
			catch
			{
				result = null;
			}
			return result;
		}
		public static Recordset GetRecordSet(string ConnectString, string FullSearchString)
		{
			Recordset result;
			try
			{
				OleDbConnection oleDbConnection = new OleDbConnection(ConnectString);
				Workspace workspace = gf.DAODBEngine_definst.Workspaces[0];
				Database database = workspace.OpenDatabase(oleDbConnection.DataSource, false, false, null);
				Recordset recordset = database.OpenRecordset(FullSearchString, RecordsetTypeEnum.dbOpenDynaset, RecordsetOptionEnum.dbConsistent, LockTypeEnum.dbOptimistic);
				result = recordset;
			}
			catch
			{
				result = null;
			}
			return result;
		}
		public static Recordset GetTableRecordSet(Database db, string TableName)
		{
			Recordset result;
			try
			{
				Recordset recordset = db.OpenRecordset(TableName, RecordsetTypeEnum.dbOpenTable, RecordsetOptionEnum.dbConsistent, LockTypeEnum.dbOptimistic);
				result = recordset;
				return result;
			}
			catch
			{
			}
			result = null;
			return result;
		}
		public static Recordset GetTableRecordSet(string ConnectString, string TableName)
		{
			Recordset result;
			try
			{
				OleDbConnection oleDbConnection = new OleDbConnection(ConnectString);
				Workspace workspace = gf.DAODBEngine_definst.Workspaces[0];
				Database database = workspace.OpenDatabase(oleDbConnection.DataSource, false, false, null);
				Recordset recordset = database.OpenRecordset(TableName, RecordsetTypeEnum.dbOpenTable, RecordsetOptionEnum.dbConsistent, LockTypeEnum.dbOptimistic);
				result = recordset;
				return result;
			}
			catch
			{
			}
			result = null;
			return result;
		}
		public static string RestoreOriginalSongsDatabase()
		{
			string text = Application.StartupPath + "\\Sys\\EasiSlidesDb.mdb";
			gf.RestoreSongsDatabase = false;
			string result;
			if (File.Exists(text))
			{
				try
				{
					gf.MakeDir(gf.RootEasiSlidesDir + "Admin\\Database\\");
					int num = 1;
					string text2 = gf.DBFileName;
					if (File.Exists(text2))
					{
						text2 = string.Concat(new string[]
						{
							gf.RootEasiSlidesDir,
							"Admin\\Database\\",
							Path.GetFileNameWithoutExtension("EasiSlidesDb.mdb"),
							DateTime.Now.ToString("-yyyy-MM-dd-"),
							num.ToString(),
							Path.GetExtension("EasiSlidesDb.mdb")
						});
						while (File.Exists(text2))
						{
							num++;
							text2 = string.Concat(new string[]
							{
								gf.RootEasiSlidesDir,
								"Admin\\Database\\",
								Path.GetFileNameWithoutExtension("EasiSlidesDb.mdb"),
								DateTime.Now.ToString("-yyyy-MM-dd-"),
								num.ToString(),
								Path.GetExtension("EasiSlidesDb.mdb")
							});
						}
					}
					else
					{
						text2 = "";
					}
					try
					{
						if (text2 != "")
						{
							File.Move(gf.DBFileName, text2);
						}
						File.Copy(text, gf.DBFileName);
						result = text2;
						return result;
					}
					catch
					{
					}
					MessageBox.Show("Sorry, cannot install the new Lyrics Database. Please make sure the existing database is not in use and then try again.");
					result = "-1";
					return result;
				}
				catch
				{
					MessageBox.Show("Sorry, cannot install the new Lyrics Database. Please make sure the existing database is not in use and then try again.");
					result = "-1";
					return result;
				}
			}
			MessageBox.Show("Sorry, cannot install the new Lyrics Database. Please re-install EasiSlides Software.");
			result = "-1";
			return result;
		}
		public static void RestoreBackgroundImages()
		{
			string text = Application.StartupPath + "\\Backgrounds\\Scenery\\";
			string text2 = Application.StartupPath + "\\Backgrounds\\Tiles\\";
			string text3 = gf.RootEasiSlidesDir + "Images\\Scenery\\";
			string text4 = gf.RootEasiSlidesDir + "Images\\Tiles\\";
			if (gf.MakeDir(gf.RootEasiSlidesDir + "Images\\"))
			{
				if (Directory.Exists(text))
				{
					if (gf.MakeDir(text3))
					{
						gf.CopyFiles(text, text3);
					}
				}
				if (Directory.Exists(text2))
				{
					if (gf.MakeDir(text4))
					{
						gf.CopyFiles(text2, text4);
					}
				}
			}
		}
		public static void CopyFiles(string SrcFolder, string DestFolder)
		{
			gf.MakeDir(DestFolder);
			try
			{
				DirectoryInfo directoryInfo = new DirectoryInfo(SrcFolder);
				string[] files = Directory.GetFiles(SrcFolder, "*.*");
				string[] array = files;
				for (int i = 0; i < array.Length; i++)
				{
					string text = array[i];
					try
					{
						File.Copy(text, DestFolder + "\\" + Path.GetFileName(text), false);
					}
					catch
					{
					}
				}
			}
			catch
			{
			}
		}
		public static bool ValidateDB(gf.DatabaseType InType)
		{
			string text;
			string str;
			if (InType == gf.DatabaseType.Usages)
			{
				text = gf.UsageFileName;
				str = "Usage";
			}
			else
			{
				if (InType == gf.DatabaseType.Bible)
				{
					text = gf.BiblesListFileName;
					str = "Bible List";
				}
				else
				{
					text = gf.DBFileName;
					str = "EasiSlides";
				}
			}
			bool result;
			if (File.Exists(text))
			{
				result = true;
			}
			else
			{
				string text2 = Application.StartupPath + "\\Sys\\Defdb.dat";
				if (File.Exists(text2))
				{
					Directory.CreateDirectory(gf.RootEasiSlidesDir + "Admin\\Database\\");
					File.Copy(text2, text, true);
					result = true;
				}
				else
				{
					gf.MessageOverSplashScreen("Sorry, cannot create new " + str + " database. Please re-install EasiSlides Software.");
					result = false;
				}
			}
			return result;
		}
		public static bool DeleteAllFolders(string InConnectString)
		{
			bool result;
			if (InConnectString == "" || InConnectString == gf.ConnectStringMainDB)
			{
				result = false;
			}
			else
			{
				try
				{
					OleDbConnection oleDbConnection = new OleDbConnection(InConnectString);
					OleDbCommand oleDbCommand = new OleDbCommand("Delete * from Folder ", oleDbConnection);
					oleDbConnection.Open();
					oleDbCommand.ExecuteNonQuery();
					oleDbConnection.Close();
					result = true;
					return result;
				}
				catch
				{
				}
				result = false;
			}
			return result;
		}
		public static void ResetFolder(int FNumber, string InFolderName, string InConnectString)
		{
			OleDbConnection oleDbConnection = new OleDbConnection(InConnectString);
			try
			{
				string text = "select count(*) from FOLDER where FolderNo=" + gf.ObjToString(FNumber);
				oleDbConnection.Open();
				OleDbCommand oleDbCommand = new OleDbCommand(text, oleDbConnection);
				if ((int)oleDbCommand.ExecuteScalar() == 0)
				{
					string value;
					bool flag;
					if (InFolderName == "")
					{
						if (FNumber > 0)
						{
							value = "Folder " + gf.ObjToString(FNumber);
							flag = (FNumber < 4);
						}
						else
						{
							value = "Recycle Folder";
							flag = false;
						}
					}
					else
					{
						value = InFolderName;
						flag = true;
					}
					text = "Insert into Folder (FolderNo,name,Use,GroupStyle,PreChorusHeading,ChorusHeading, BridgeHeading,EndingHeading,BIUHeading,HeadingSize,HeadingOption,BIU0,Size0,Bold0,Align0,FontName0,Vpos0,BIU1,Size1,Bold1,Align1,FontName1,Vpos1)  Values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
					oleDbCommand.CommandText = text;
					oleDbCommand.Parameters.AddWithValue("@FolderNo", FNumber);
					oleDbCommand.Parameters.AddWithValue("@Name", value);
					oleDbCommand.Parameters.AddWithValue("@Use", flag);
					oleDbCommand.Parameters.AddWithValue("@GroupStyle", gf.SortBy.Alpha);
					oleDbCommand.Parameters.AddWithValue("@PreChorusHeading", "");
					oleDbCommand.Parameters.AddWithValue("@ChorusHeading", "Chorus:");
					oleDbCommand.Parameters.AddWithValue("@BridgeHeading", "");
					oleDbCommand.Parameters.AddWithValue("@EndingHeading", "");
					oleDbCommand.Parameters.AddWithValue("@BIUHeading", 4);
					oleDbCommand.Parameters.AddWithValue("@HeadingSize", 100);
					oleDbCommand.Parameters.AddWithValue("@HeadingOption", gf.HeadingFormat.AsRegion1Plus);
					oleDbCommand.Parameters.AddWithValue("@BIU0", 0);
					oleDbCommand.Parameters.AddWithValue("@Size0", 40);
					oleDbCommand.Parameters.AddWithValue("@Bold0", false);
					oleDbCommand.Parameters.AddWithValue("@Align0", 2);
					oleDbCommand.Parameters.AddWithValue("@FontName0", "Microsoft Sans Serif");
					oleDbCommand.Parameters.AddWithValue("@Vpos0", 0);
					oleDbCommand.Parameters.AddWithValue("@BIU1", 0);
					oleDbCommand.Parameters.AddWithValue("@Size1", 40);
					oleDbCommand.Parameters.AddWithValue("@Bold1", false);
					oleDbCommand.Parameters.AddWithValue("@Align1", 2);
					oleDbCommand.Parameters.AddWithValue("@FontName1", "Microsoft Sans Serif");
					oleDbCommand.Parameters.AddWithValue("@Vpos1", 50);
					oleDbCommand.ExecuteNonQuery();
				}
			}
			catch
			{
			}
			finally
			{
				if (oleDbConnection.State == ConnectionState.Open)
				{
					oleDbConnection.Close();
				}
			}
		}
		public static void LoadSavedData()
		{
			for (int i = 0; i < 41; i++)
			{
				gf.FindSongsFolder[i] = true;
			}
			gf.RootEasiSlidesDir = gf.GetRegValue("config", "root_directory", "C:\\EasiSlides\\");
			gf.WorshipDir = gf.RootEasiSlidesDir + "Admin\\WorshipLists\\";
			if (!Directory.Exists(gf.WorshipDir))
			{
				gf.MakeDir(gf.WorshipDir);
			}
			gf.InfoScreenDir = gf.RootEasiSlidesDir + "InfoScreens\\";
			if (!Directory.Exists(gf.InfoScreenDir))
			{
				gf.MakeDir(gf.InfoScreenDir);
			}
			gf.PowerpointDir = gf.RootEasiSlidesDir + "Powerpoint\\";
			if (!Directory.Exists(gf.PowerpointDir))
			{
				gf.MakeDir(gf.PowerpointDir);
			}
			gf.BibleDir = gf.RootEasiSlidesDir + "HolyBibles\\";
			if (!Directory.Exists(gf.BibleDir))
			{
				gf.MakeDir(gf.BibleDir);
			}
			gf.PraiseBookDir = gf.RootEasiSlidesDir + "Admin\\PraiseBooks\\";
			if (!Directory.Exists(gf.PraiseBookDir))
			{
				gf.MakeDir(gf.PraiseBookDir);
			}
			gf.WorshipTemplatesDir = gf.RootEasiSlidesDir + "Admin\\Templates\\WorshipListsTemplates\\";
			if (!Directory.Exists(gf.WorshipTemplatesDir))
			{
				gf.MakeDir(gf.WorshipTemplatesDir);
			}
			gf.SettingsTemplatesDir = gf.RootEasiSlidesDir + "Admin\\Templates\\SettingsTemplates\\";
			if (!Directory.Exists(gf.SettingsTemplatesDir))
			{
				gf.MakeDir(gf.SettingsTemplatesDir);
			}
			gf.EasiSlidesTempDir = Path.GetTempPath() + "Temporary EasiSlides Files\\";
			if (!Directory.Exists(gf.EasiSlidesTempDir))
			{
				gf.MakeDir(gf.EasiSlidesTempDir);
			}
			gf.MediaDir = gf.RootEasiSlidesDir + "Media\\";
			if (!Directory.Exists(gf.MediaDir))
			{
				gf.MakeDir(gf.MediaDir);
			}
			gf.DocumentsDir = gf.RootEasiSlidesDir + "Documents\\";
			if (!Directory.Exists(gf.DocumentsDir))
			{
				gf.MakeDir(gf.DocumentsDir);
			}
			gf.ImagesDir = gf.RootEasiSlidesDir + "Images\\";
			if (!Directory.Exists(gf.ImagesDir))
			{
				gf.RestoreBackgroundImages();
			}
			if (!Directory.Exists(gf.ImagesDir + "Tiles\\") || !Directory.Exists(gf.ImagesDir + "Scenery\\"))
			{
				gf.RestoreBackgroundImages();
			}
			gf.CurSession = gf.GetRegValue("config", "current_session", "");
			gf.CurPraiseBook = gf.GetRegValue("config", "current_praisebook", "");
			string text = gf.GetRegValue("config", "media_dir", gf.MediaDir);
			if (gf.Right(text, 1) != "\\")
			{
				text += "\\";
			}
			if (Directory.Exists(text))
			{
				gf.MediaDir = text;
			}
			gf.ExportToDir = gf.GetRegValue("config", "export_dir", gf.DocumentsDir);
			if (gf.Right(gf.ExportToDir, 1) != "\\")
			{
				gf.ExportToDir += "\\";
			}
			gf.ImportFromDir = gf.GetRegValue("config", "import_dir", gf.DocumentsDir);
			if (gf.Right(gf.ImportFromDir, 1) != "\\")
			{
				gf.ImportFromDir += "\\";
			}
			gf.PraiseOutputDir = gf.GetRegValue("config", "praiseoutput_dir", gf.DocumentsDir);
			if (gf.Right(gf.PraiseOutputDir, 1) != "\\")
			{
				gf.PraiseOutputDir += "\\";
			}
			gf.CurPraiseBook = gf.GetRegValue("config", "current_praisebook", "");
			gf.UseSongNumbers = (gf.ObjToInt(gf.GetRegValue("options", "UseSongNumbers", 0)) > 0);
			gf.PB_PrinterSpaces = ((gf.ObjToInt(gf.GetRegValue("options", "PrinterSpaces", 0)) > 0) ? 1 : 0);
			gf.HB_MaxVersesSelection = gf.ObjToInt(gf.GetRegValue("options", "BibleMaxSelectVerses", 500));
			if (gf.HB_MaxVersesSelection > 100)
			{
				gf.HB_MaxVersesSelection = 100;
			}
			gf.HB_MaxAdhocVersesSelection = gf.ObjToInt(gf.GetRegValue("options", "BibleMaxAdhocVersesSelection", 200));
			if (gf.HB_MaxAdhocVersesSelection > 100)
			{
				gf.HB_MaxAdhocVersesSelection = 100;
			}
			gf.HB_ShowVerses = true;
			gf.PP_MaxFiles = gf.ObjToInt(gf.GetRegValue("options", "PowerpointMaxFiles", 20));
			if (gf.PP_MaxFiles > 100)
			{
				gf.PP_MaxFiles = 100;
			}
			gf.ShowRotateGap = gf.ObjToInt(gf.GetRegValue("options", "RotateGap", 0));
			if (gf.ShowRotateGap < 0 & gf.ShowRotateGap > 999)
			{
				gf.ShowRotateGap = 0;
			}
			gf.UsePowerpointTab = (gf.ObjToInt(gf.GetRegValue("options", "UsePowerpointTab", 0)) > 0);
			gf.NoPowerpointPanelOverlay = (gf.ObjToInt(gf.GetRegValue("options", "NoPowerpointPanelOverlay", 0)) > 0);
			gf.UseMediaTab = (gf.ObjToInt(gf.GetRegValue("options", "UseMediaTab", 0)) > 0);
			gf.ShowLyricsMonitorAlertBox = (gf.ObjToInt(gf.GetRegValue("options", "ShowLyricsMonitorAlertBox", 0)) > 0);
			gf.NoMediaPanelOverlay = (gf.ObjToInt(gf.GetRegValue("options", "NoMediaPanelOverlay", 0)) > 0);
			gf.AutoTextOverflow = (gf.ObjToInt(gf.GetRegValue("options", "AutoTextOverflow", 1)) > 0);
			gf.UseLargestFontSize = (gf.ObjToInt(gf.GetRegValue("options", "UseLargestFontSize", 0)) > 0);
			gf.AdvanceNextItem = (gf.ObjToInt(gf.GetRegValue("options", "AdvanceNextItem", 0)) > 0);
			gf.LineBetweenRegions = (gf.ObjToInt(gf.GetRegValue("options", "LineBetweenRegions", 1)) > 0);
			gf.GapItemOption = (gf.GapType)gf.ObjToInt(gf.GetRegValue("options", "GapItemOption", 0));
			if (gf.GapItemOption < gf.GapType.None & gf.GapItemOption > gf.GapType.User)
			{
				gf.GapItemOption = gf.GapType.None;
			}
			gf.AltGapItemOption = gf.GapType.None;
			gf.GapItemLogoFile = gf.GetRegValue("options", "GapItemLogoFile", "");
			gf.GapItemUseFade = (gf.ObjToInt(gf.GetRegValue("options", "GapItemUseFade", 1)) > 0);
			gf.WordWrapLeftAlignIndent = (gf.ObjToInt(gf.GetRegValue("options", "WordWrapLeftAlignIndent", 1)) > 0);
			gf.WordWrapIgnoreStartSpaces = gf.ObjToInt(gf.GetRegValue("options", "WordWrapIgnoreStartSpaces", 8));
			if (gf.WordWrapIgnoreStartSpaces < 1 || gf.WordWrapIgnoreStartSpaces > 15)
			{
				gf.WordWrapIgnoreStartSpaces = 9;
			}
			gf.AutoRotateOn = (gf.ObjToInt(gf.GetRegValue("options", "AutoRotateOn", 1)) > 0);
			gf.AutoRotateStyle = gf.ObjToInt(gf.GetRegValue("options", "AutoRotateStyle", 3));
			if (gf.AutoRotateStyle < 1 & gf.AutoRotateStyle > 3)
			{
				gf.AutoRotateStyle = 3;
			}
			int num = gf.ObjToInt(gf.GetRegValue("options", "NotationFontFactor", 75));
			if (num < 20 & num > 200)
			{
				num = 75;
			}
			gf.NotationFontFactor = (double)((float)num / 100f);
			gf.PowerpointListingStyle = gf.ObjToInt(gf.GetRegValue("options", "ExternalListing", 0));
			if (gf.PowerpointListingStyle < 0 & gf.PowerpointListingStyle > 1)
			{
				gf.PowerpointListingStyle = 0;
			}
			gf.KeyBoardOption = gf.ObjToInt(gf.GetRegValue("options", "KeyBoardOption", 0));
			if (gf.KeyBoardOption < 0 & gf.KeyBoardOption > 1)
			{
				gf.KeyBoardOption = 0;
			}
			gf.EditMainFontName = gf.GetRegValue("options", "EditMainFontName", "Microsoft Sans Serif");
			if (gf.EditMainFontName == "")
			{
				gf.EditMainFontName = "Microsoft Sans Serif";
			}
			gf.EditMainFontSize = gf.ObjToInt(gf.GetRegValue("options", "EditMainFontSize", 12));
			if (gf.EditMainFontSize < 8 | gf.EditMainFontSize > 20)
			{
				gf.EditMainFontSize = 12;
			}
			gf.EditNotationFontSize = gf.ObjToInt(gf.GetRegValue("options", "EditNotationFontSize", 10));
			if (gf.EditNotationFontSize < 8 | gf.EditNotationFontSize > 20)
			{
				gf.EditNotationFontSize = 10;
			}
			gf.InfoMainFontName = gf.GetRegValue("options", "InfoMainFontName", "Microsoft Sans Serif");
			if (gf.InfoMainFontName == "")
			{
				gf.InfoMainFontName = "Microsoft Sans Serif";
			}
			gf.InfoMainFontSize = gf.ObjToInt(gf.GetRegValue("options", "InfoMainFontSize", 12));
			if (gf.InfoMainFontSize < 8 | gf.InfoMainFontSize > 20)
			{
				gf.InfoMainFontSize = 12;
			}
			gf.EditOpenDocumentDir = gf.GetRegValue("options", "EditOpenDocumentDir", gf.DocumentsDir);
			if (gf.EditOpenDocumentDir == "")
			{
				gf.EditOpenDocumentDir = gf.DocumentsDir;
			}
			gf.OutputMonitorNumber = gf.ObjToInt(gf.GetRegValue("options", "OutputmonitorNumber", 1));
			gf.LyricsMonitorNumber = gf.ObjToInt(gf.GetRegValue("options", "LyricsMonitorNumber", 0));
			gf.BibleText_FontSize = gf.ObjToInt(gf.GetRegValue("options", "BibleTextFontSize", 8));
			if (gf.BibleText_FontSize < 8 | gf.BibleText_FontSize > 20)
			{
				gf.BibleText_FontSize = 8;
			}
			gf.PreviewArea_FontSize = gf.ObjToInt(gf.GetRegValue("options", "PreviewAreaFontSize", 8));
			if (gf.PreviewArea_FontSize < 8 | gf.PreviewArea_FontSize > 20)
			{
				gf.PreviewArea_FontSize = 8;
			}
			gf.PreviewArea_ShowNotations = (gf.ObjToInt(gf.GetRegValue("options", "PreviewAreaShowNotations", 0)) > 0);
			gf.PreviewArea_LineBetweenScreens = (gf.ObjToInt(gf.GetRegValue("options", "PreviewAreaLineBetweenScreens", 0)) > 0);
			gf.ParentalAlertHeading = gf.GetRegValue("options", "ParentalAlertHeading", "");
			gf.ParentalAlertDuration = gf.ObjToInt(gf.GetRegValue("options", "ParentalAlertDuration", 20));
			if (gf.ParentalAlertDuration < 1 | gf.ParentalAlertDuration > 60)
			{
				gf.ParentalAlertDuration = 30;
			}
			gf.ParentalAlertTextColour = Color.FromArgb(gf.ObjToInt(gf.GetRegValue("options", "ParentalAlertTextColour", gf.ParentalAlertTextColour.ToArgb())));
			gf.ParentalAlertBackColour = Color.FromArgb(gf.ObjToInt(gf.GetRegValue("options", "ParentalAlertBackColour", gf.ParentalAlertBackColour.ToArgb())));
			gf.ParentalAlertTextAlign = gf.ObjToInt(gf.GetRegValue("options", "ParentalAlertTextAlign", 3));
			if (gf.ParentalAlertTextAlign < 1 | gf.ParentalAlertTextAlign > 3)
			{
				gf.ParentalAlertTextAlign = 3;
			}
			gf.ParentalAlertVerticalAlign = gf.ObjToInt(gf.GetRegValue("options", "ParentalAlertVerticalAlign", 2));
			if (gf.ParentalAlertVerticalAlign < 0 | gf.ParentalAlertVerticalAlign > 2)
			{
				gf.ParentalAlertVerticalAlign = 2;
			}
			int inValue = gf.ObjToInt(gf.GetRegValue("options", "ParentalAlertStyle", 3));
			gf.ParentalAlertScroll = gf.GetBitBoolean(inValue, 1);
			gf.ParentalAlertFlash = gf.GetBitBoolean(inValue, 2);
			gf.ParentalAlertTransparent = gf.GetBitBoolean(inValue, 3);
			gf.ParentalAlertFontName = gf.GetRegValue("options", "ParentalAlertFontName", "Microsoft Sans Serif");
			if (gf.ParentalAlertFontName == "")
			{
				gf.ParentalAlertFontName = "Microsoft Sans Serif";
			}
			gf.ParentalAlertFontSize = gf.ObjToInt(gf.GetRegValue("options", "ParentalAlertFontSize", 22));
			if (gf.ParentalAlertFontSize < 20 | gf.ParentalAlertFontSize > 50)
			{
				gf.ParentalAlertFontSize = 25;
			}
			gf.ParentalAlertFontFormat = gf.ObjToInt(gf.GetRegValue("options", "ParentalAlertFontFormat", 0));
			if (gf.ParentalAlertFontFormat < 0 | gf.ParentalAlertFontFormat > 100)
			{
				gf.ParentalAlertFontFormat = 0;
			}
			gf.ParentalAlertBold = gf.GetBitBoolean(gf.ParentalAlertFontFormat, 1);
			gf.ParentalAlertItalic = gf.GetBitBoolean(gf.ParentalAlertFontFormat, 2);
			gf.ParentalAlertUnderline = gf.GetBitBoolean(gf.ParentalAlertFontFormat, 3);
			gf.ParentalAlertShadow = gf.GetBitBoolean(gf.ParentalAlertFontFormat, 4);
			gf.ParentalAlertOutline = gf.GetBitBoolean(gf.ParentalAlertFontFormat, 5);
			gf.MessageAlertDuration = gf.ObjToInt(gf.GetRegValue("options", "MessageAlertDuration", 20));
			if (gf.MessageAlertDuration < 1 | gf.MessageAlertDuration > 999)
			{
				gf.MessageAlertDuration = 30;
			}
			gf.MessageAlertTextColour = Color.FromArgb(gf.ObjToInt(gf.GetRegValue("options", "MessageAlertTextColour", gf.MessageAlertTextColour.ToArgb())));
			gf.MessageAlertBackColour = Color.FromArgb(gf.ObjToInt(gf.GetRegValue("options", "MessageAlertBackColour", gf.MessageAlertBackColour.ToArgb())));
			gf.MessageAlertTextAlign = gf.ObjToInt(gf.GetRegValue("options", "MessageAlertTextAlign", 2));
			if (gf.MessageAlertTextAlign < 1 | gf.MessageAlertTextAlign > 3)
			{
				gf.MessageAlertTextAlign = 2;
			}
			gf.MessageAlertVerticalAlign = gf.ObjToInt(gf.GetRegValue("options", "MessageAlertVerticalAlign", 2));
			if (gf.MessageAlertVerticalAlign < 0 | gf.MessageAlertVerticalAlign > 2)
			{
				gf.MessageAlertVerticalAlign = 2;
			}
			int inValue2 = gf.ObjToInt(gf.GetRegValue("options", "MessageAlertStyle", 3));
			gf.MessageAlertScroll = gf.GetBitBoolean(inValue2, 1);
			gf.MessageAlertFlash = gf.GetBitBoolean(inValue2, 2);
			gf.MessageAlertTransparent = gf.GetBitBoolean(inValue2, 3);
			gf.MessageAlertFontName = gf.GetRegValue("options", "MessageAlertFontName", "Microsoft Sans Serif");
			if (gf.MessageAlertFontName == "")
			{
				gf.MessageAlertFontName = "Microsoft Sans Serif";
			}
			gf.MessageAlertFontSize = gf.ObjToInt(gf.GetRegValue("options", "MessageAlertFontSize", 22));
			if (gf.MessageAlertFontSize < 20 | gf.MessageAlertFontSize > 50)
			{
				gf.MessageAlertFontSize = 25;
			}
			gf.MessageAlertFontFormat = gf.ObjToInt(gf.GetRegValue("options", "MessageAlertFontFormat", 0));
			if (gf.MessageAlertFontFormat < 0 | gf.MessageAlertFontFormat > 100)
			{
				gf.MessageAlertFontFormat = 0;
			}
			gf.MessageAlertBold = gf.GetBitBoolean(gf.MessageAlertFontFormat, 1);
			gf.MessageAlertItalic = gf.GetBitBoolean(gf.MessageAlertFontFormat, 2);
			gf.MessageAlertUnderline = gf.GetBitBoolean(gf.MessageAlertFontFormat, 3);
			gf.MessageAlertShadow = gf.GetBitBoolean(gf.MessageAlertFontFormat, 4);
			gf.MessageAlertOutline = gf.GetBitBoolean(gf.MessageAlertFontFormat, 5);
			gf.ReferenceAlertDuration = gf.ObjToInt(gf.GetRegValue("options", "ReferenceAlertDuration", 20));
			if (gf.ReferenceAlertDuration < 1 | gf.ReferenceAlertDuration > 999)
			{
				gf.ReferenceAlertDuration = 30;
			}
			gf.ReferenceAlertTextColour = Color.FromArgb(gf.ObjToInt(gf.GetRegValue("options", "ReferenceAlertTextColour", gf.BlackScreenColour.ToArgb())));
			gf.ReferenceAlertBackColour = Color.FromArgb(gf.ObjToInt(gf.GetRegValue("options", "ReferenceAlertBackColour", Color.White.ToArgb())));
			gf.ReferenceAlertTextAlign = gf.ObjToInt(gf.GetRegValue("options", "ReferenceAlertTextAlign", 3));
			if (gf.ReferenceAlertTextAlign < 1 | gf.ReferenceAlertTextAlign > 3)
			{
				gf.ReferenceAlertTextAlign = 3;
			}
			gf.ReferenceAlertVerticalAlign = gf.ObjToInt(gf.GetRegValue("options", "ReferenceAlertVerticalAlign", 1));
			if (gf.ReferenceAlertVerticalAlign < 0 | gf.ReferenceAlertVerticalAlign > 2)
			{
				gf.ReferenceAlertVerticalAlign = 1;
			}
			int inValue3 = gf.ObjToInt(gf.GetRegValue("options", "ReferenceAlertStyle", 1));
			gf.ReferenceAlertScroll = gf.GetBitBoolean(inValue3, 1);
			gf.ReferenceAlertFlash = gf.GetBitBoolean(inValue3, 2);
			gf.ReferenceAlertTransparent = gf.GetBitBoolean(inValue3, 3);
			gf.ReferenceAlertFontName = gf.GetRegValue("options", "ReferenceAlertFontName", "Microsoft Sans Serif");
			if (gf.ReferenceAlertFontName == "")
			{
				gf.ReferenceAlertFontName = "Microsoft Sans Serif";
			}
			gf.ReferenceAlertFontSize = gf.ObjToInt(gf.GetRegValue("options", "ReferenceAlertFontSize", 22));
			if (gf.ReferenceAlertFontSize < 20 | gf.ReferenceAlertFontSize > 50)
			{
				gf.ReferenceAlertFontSize = 25;
			}
			gf.ReferenceAlertFontFormat = gf.ObjToInt(gf.GetRegValue("options", "ReferenceAlertFontFormat", 0));
			if (gf.ReferenceAlertFontFormat < 0 | gf.ReferenceAlertFontFormat > 100)
			{
				gf.ReferenceAlertFontFormat = 0;
			}
			gf.ReferenceAlertBold = gf.GetBitBoolean(gf.ReferenceAlertFontFormat, 1);
			gf.ReferenceAlertItalic = gf.GetBitBoolean(gf.ReferenceAlertFontFormat, 2);
			gf.ReferenceAlertUnderline = gf.GetBitBoolean(gf.ReferenceAlertFontFormat, 3);
			gf.ReferenceAlertShadow = gf.GetBitBoolean(gf.ReferenceAlertFontFormat, 4);
			gf.ReferenceAlertOutline = gf.GetBitBoolean(gf.ReferenceAlertFontFormat, 5);
			gf.ReferenceAlertUsePick = (gf.ObjToInt(gf.GetRegValue("options", "ReferenceAlertUsePick", 0)) > 0);
			gf.ReferenceAlertBlankIfPickNotFound = (gf.ObjToInt(gf.GetRegValue("options", "ReferenceAlertBlankIfPickNotFound", 0)) > 0);
			gf.ReferenceAlertSource = gf.ObjToInt(gf.GetRegValue("options", "ReferenceAlertSource", 0));
			gf.ReferenceAlertPickName = gf.GetRegValue("options", "ReferenceAlertPickName", "");
			gf.ReferenceAlertPickSubstitute = gf.GetRegValue("options", "ReferenceAlertPickSubstitute", "");
			gf.ReferenceAlertPickSeparator = gf.GetRegValue("options", "ReferenceAlertPickSeparator", ",");
			gf.UpdateV4RegDM();
			gf.DMAlwaysUse = (gf.ObjToInt(gf.GetRegValue("monitors", "AlwaysTryDualMonitor", 1)) > 0);
			gf.DMOption = gf.ObjToInt(gf.GetRegValue("monitors", "DualMonitorOption", 0));
			if (gf.DMOption < 0 | gf.DMOption > 1)
			{
				gf.DMOption = 0;
			}
			gf.DMOption1Left = gf.ObjToInt(gf.GetRegValue("monitors", "DualMonitorOptionCustomLeft", 0));
			if (gf.DMOption1Left < -9999 | gf.DMOption1Left > 9999)
			{
				gf.DMOption1Left = 0;
			}
			gf.DMOption1Top = gf.ObjToInt(gf.GetRegValue("monitors", "DualMonitorOptionCustomTop", 0));
			if (gf.DMOption1Top < -9999 | gf.DMOption1Top > 9999)
			{
				gf.DMOption1Top = 0;
			}
			gf.DMOption1Width = gf.ObjToInt(gf.GetRegValue("monitors", "DualMonitorOptionCustomWidth", 1));
			if (gf.DMOption1Width < 1 | gf.DMOption1Width > 9999)
			{
				gf.DMOption1Width = 100;
			}
			gf.DMOption1Height = gf.DMOption1Width * 3 / 4;
			if (gf.DMOption1Height < 1)
			{
				gf.DMOption1Height = 1;
			}
			gf.DMOption1AsSingleMonitor = (gf.ObjToInt(gf.GetRegValue("monitors", "DualMonitorOptionCustomAsSingle", 0)) > 0);
			gf.DisableSreenSaver = (gf.ObjToInt(gf.GetRegValue("monitors", "DisableSreenSaver", 1)) > 0);
			gf.VideoSize = gf.ObjToInt(gf.GetRegValue("monitors", "VideoSize", 100));
			if (gf.VideoSize < 25 | gf.VideoSize > 100)
			{
				gf.VideoSize = 100;
			}
			gf.VideoVAlign = gf.ObjToInt(gf.GetRegValue("monitors", "VideoVAlign", 1));
			if (gf.VideoVAlign < 0 | gf.VideoVAlign > 2)
			{
				gf.VideoVAlign = 1;
			}
			gf.LMAlwaysUse = (gf.ObjToInt(gf.GetRegValue("monitors", "AlwaysTrySecondaryLyricsMonitor", 1)) > 0);
			gf.LMOption = gf.ObjToInt(gf.GetRegValue("monitors", "LyricsMonitorOption", 0));
			if (gf.LMOption < 0 | gf.LMOption > 1)
			{
				gf.LMOption = 0;
			}
			gf.LMOption1Left = gf.ObjToInt(gf.GetRegValue("monitors", "LyricsMonitorOptionCustomLeft", 0));
			if (gf.LMOption1Left < -9999 | gf.LMOption1Left > 9999)
			{
				gf.LMOption1Left = 0;
			}
			gf.LMOption1Top = gf.ObjToInt(gf.GetRegValue("monitors", "LyricsMonitorOptionCustomTop", 0));
			if (gf.LMOption1Top < -9999 | gf.LMOption1Top > 9999)
			{
				gf.LMOption1Top = 0;
			}
			gf.LMOption1Width = gf.ObjToInt(gf.GetRegValue("monitors", "LyricsMonitorOptionCustomWidth", 1));
			if (gf.LMOption1Width < 1 | gf.LMOption1Width > 9999)
			{
				gf.LMOption1Width = 100;
			}
			gf.LMOption1Height = gf.LMOption1Width * 3 / 4;
			if (gf.LMOption1Height < 1)
			{
				gf.LMOption1Height = 1;
			}
			gf.LMTextColour = Color.FromArgb(gf.ObjToInt(gf.GetRegValue("monitors", "LyricsMonitorTextColour", gf.LMTextColour.ToArgb())));
			gf.LMHighlightColour = Color.FromArgb(gf.ObjToInt(gf.GetRegValue("monitors", "LyricsMonitorHighlightColour", gf.LMHighlightColour.ToArgb())));
			gf.LMBackColour = Color.FromArgb(gf.ObjToInt(gf.GetRegValue("monitors", "LyricsMonitorBackColour", gf.LMBackColour.ToArgb())));
			gf.LMShowNotations = (gf.ObjToInt(gf.GetRegValue("monitors", "LyricsMonitorShowNotations", 1)) > 0);
			gf.LMMainFontSize = gf.ObjToInt(gf.GetRegValue("monitors", "LyricsMonitorFontSize", 22));
			if (gf.LMMainFontSize < 8 | gf.LMMainFontSize > 40)
			{
				gf.LMMainFontSize = 20;
			}
			gf.LMNotationsFontSize = gf.ObjToInt(gf.GetRegValue("options", "LyricsMonitorNotationsFontSize", 22));
			if (gf.LMNotationsFontSize < 8 | gf.LMNotationsFontSize > 40)
			{
				gf.LMNotationsFontSize = 20;
			}
			gf.LMFontFormat = gf.ObjToInt(gf.GetRegValue("options", "LyricsMonitorFontFormat", 0));
			if (gf.LMFontFormat < 0 | gf.LMFontFormat > 7)
			{
				gf.LMFontFormat = 0;
			}
			gf.LMFontBold = gf.GetBitBoolean(gf.LMFontFormat, 1);
			gf.LMFontItalic = gf.GetBitBoolean(gf.LMFontFormat, 2);
			gf.LMFontUnderline = gf.GetBitBoolean(gf.LMFontFormat, 3);
			gf.AutoFocusTextRegion = false;
			gf.UseFocusedTextRegionColour = (gf.ObjToInt(gf.GetRegValue("options", "UseFocusedBackColour", 1)) > 0);
			gf.FocusedTextRegionColour = Color.FromArgb(gf.ObjToInt(gf.GetRegValue("options", "FocusedBackColour", gf.FocusedTextRegionColour.ToArgb())));
			gf.TextRegionSlideTextColour = Color.FromArgb(gf.ObjToInt(gf.GetRegValue("options", "SelectedSlideTextColour", gf.TextRegionSlideTextColour.ToArgb())));
            gf.TextRegionSlideBackColour = Color.Yellow;//Color.FromArgb(gf.ObjToInt(gf.GetRegValue("options", "SelectedSlideBackColour", gf.TextRegionSlideBackColour.ToArgb())));
			gf.TotalMediaFileExt = 0;
			gf.MediaExtensionsDatafile = gf.RootEasiSlidesDir + "Admin\\Database\\MediaExtensions.txt";
			gf.AudioExtensionsDatafile = gf.RootEasiSlidesDir + "Admin\\Database\\AudioExtensions.txt";
			gf.VideoExtensionsDatafile = gf.RootEasiSlidesDir + "Admin\\Database\\VideoExtensions.txt";
			gf.LoadMusicExtArray();
			gf.JumpToA = gf.ObjToInt(gf.GetRegValue("options", "JumpToA", 1));
			if (gf.JumpToA < 1 | gf.JumpToA > 41)
			{
				gf.JumpToA = 1;
			}
			gf.JumpToB = gf.ObjToInt(gf.GetRegValue("options", "JumpToB", 2));
			if (gf.JumpToB < 1 | gf.JumpToB > 41)
			{
				gf.JumpToB = 2;
			}
			gf.JumpToC = gf.ObjToInt(gf.GetRegValue("options", "JumpToC", 3));
			if (gf.JumpToC < 1 | gf.JumpToC > 41)
			{
				gf.JumpToC = 3;
			}
			gf.LiveCamNumber = gf.ObjToInt(gf.GetRegValue("monitors", "LiveCamNumber", 1));
			if (gf.LiveCamNumber < 1 | gf.LiveCamNumber > 5)
			{
				gf.LiveCamNumber = 1;
			}
			gf.LiveCamVolume = gf.ObjToInt(gf.GetRegValue("monitors", "LiveCamVolume", 50));
			if (gf.LiveCamVolume < 0 | gf.LiveCamVolume > 100)
			{
				gf.LiveCamVolume = 50;
			}
			gf.LiveCamBalance = gf.ObjToInt(gf.GetRegValue("monitors", "LiveCamBalance", 0));
			if (gf.LiveCamBalance < -100 | gf.LiveCamBalance > 100)
			{
				gf.LiveCamBalance = 0;
			}
			gf.LiveCamWidescreen = (gf.ObjToInt(gf.GetRegValue("monitors", "LiveCamWidescreen", 0)) > 0);
			gf.LiveCamMute = (gf.ObjToInt(gf.GetRegValue("monitors", "LiveCamMute", 0)) > 0);
			gf.LiveCamNoPanelOverlay = (gf.ObjToInt(gf.GetRegValue("monitors", "LiveCamNoPanelOverlay", 0)) > 0);
			gf.FindItemInTitle = (gf.ObjToInt(gf.GetRegValue("options", "FindItemInTitle", 1)) > 0);
			gf.FindItemInContents = (gf.ObjToInt(gf.GetRegValue("options", "FindItemInContents", 1)) > 0);
			gf.FindItemInSongNumber = (gf.ObjToInt(gf.GetRegValue("options", "FindItemInSongNumber", 1)) > 0);
			gf.FindItemInBookRef = (gf.ObjToInt(gf.GetRegValue("options", "FindItemInBookRef", 1)) > 0);
			gf.FindItemInUserRef = (gf.ObjToInt(gf.GetRegValue("options", "FindItemInUserRef", 1)) > 0);
			gf.FindItemInLicAdmin = (gf.ObjToInt(gf.GetRegValue("options", "FindItemInLicAdmin", 1)) > 0);
			gf.FindItemInWriter = (gf.ObjToInt(gf.GetRegValue("options", "FindItemInWriter", 1)) > 0);
			gf.FindItemInCopyright = (gf.ObjToInt(gf.GetRegValue("options", "FindItemInCopyright", 1)) > 0);
			gf.FindItemUseDates = (gf.ObjToInt(gf.GetRegValue("options", "FindItemUseDates", 0)) > 0);
			DateTime findItemDateFrom = DateTime.Now.Subtract(TimeSpan.FromDays(91.0));
			string s = gf.ObjToString(gf.GetRegValue("options", "FindItemDateFrom", findItemDateFrom.ToString()));
			try
			{
				gf.FindItemDateFrom = DateTime.Parse(s);
			}
			catch
			{
				gf.FindItemDateFrom = findItemDateFrom;
			}
			s = gf.ObjToString(gf.GetRegValue("options", "FindItemDateTo", DateTime.Now.ToString()));
			try
			{
				gf.FindItemDateTo = DateTime.Parse(s);
			}
			catch
			{
				gf.FindItemDateTo = DateTime.Now;
			}
			gf.OutlineFontSizeThreshold = gf.ObjToInt(gf.GetRegValue("options", "OutlineFontSizeThreshold", 55));
			if (gf.OutlineFontSizeThreshold < 25 | gf.OutlineFontSizeThreshold > 100)
			{
				gf.OutlineFontSizeThreshold = 55;
			}
			gf.OUTPPPrefix = gf.EasiSlidesTempDir + "~OUTPPPreview";
			gf.PREPPPrefix = gf.EasiSlidesTempDir + "~PREPPPreview";
			gf.ExtPPrefix = gf.EasiSlidesTempDir + "ExtPPPreview";
			gf.LoadFolderNamesArray();
			gf.ComputeShowLineSpacing();
			gf.LoadLicAdminDetails();
			gf.SaveConfigSettings();
		}
		public static void UpdateV4RegDM()
		{
			if (gf.ObjToInt(gf.GetRegValue("options", "AlwaysTryDualMonitor", -1)) >= 0)
			{
				gf.DMAlwaysUse = (gf.ObjToInt(gf.GetRegValue("options", "AlwaysTryDualMonitor", 1)) > 0);
				gf.DMOption = gf.ObjToInt(gf.GetRegValue("options", "DualMonitorOption", 0));
				gf.DMOption1Left = gf.ObjToInt(gf.GetRegValue("options", "DualMonitorOptionCustomLeft", 0));
				gf.DMOption1Top = gf.ObjToInt(gf.GetRegValue("options", "DualMonitorOptionCustomTop", 0));
				gf.DMOption1Width = gf.ObjToInt(gf.GetRegValue("options", "DualMonitorOptionCustomWidth", 1));
				gf.SaveRegValue("monitors", "AlwaysTryDualMonitor", gf.DMAlwaysUse ? 1 : 0);
				gf.SaveRegValue("monitors", "DualMonitorOption", gf.DMOption);
				gf.SaveRegValue("monitors", "DualMonitorOptionCustomLeft", gf.DMOption1Left);
				gf.SaveRegValue("monitors", "DualMonitorOptionCustomTop", gf.DMOption1Top);
				gf.SaveRegValue("monitors", "DualMonitorOptionCustomWidth", gf.DMOption1Width);
				gf.DeleletRegKey("options", "AlwaysTryDualMonitor");
				gf.DeleletRegKey("options", "DualMonitorOption");
				gf.DeleletRegKey("options", "DualMonitorOptionCustomLeft");
				gf.DeleletRegKey("options", "DualMonitorOptionCustomTop");
				gf.DeleletRegKey("options", "DualMonitorOptionCustomWidth");
			}
		}
		public static bool GetBitBoolean(int InValue, int BitRequired)
		{
			return gf.GetBitValue(InValue, BitRequired) > 0;
		}
		public static int GetBitValue(int InValue, int BitRequired)
		{
			if (InValue < 0)
			{
				InValue = 0;
			}
			int num = 0;
			if (BitRequired == 1)
			{
				num = (InValue & 1) / 1;
			}
			else
			{
				if (BitRequired == 2)
				{
					num = (InValue & 2) / 2;
				}
				else
				{
					if (BitRequired == 3)
					{
						num = (InValue & 4) / 4;
					}
					else
					{
						if (BitRequired == 4)
						{
							num = (InValue & 8) / 8;
						}
						else
						{
							if (BitRequired == 5)
							{
								num = (InValue & 16) / 16;
							}
							else
							{
								if (BitRequired == 6)
								{
									num = (InValue & 32) / 32;
								}
								else
								{
									if (BitRequired == 7)
									{
										num = (InValue & 64) / 64;
									}
									else
									{
										if (BitRequired == 8)
										{
											num = (InValue & 128) / 128;
										}
									}
								}
							}
						}
					}
				}
			}
			return (num > 0) ? 1 : 0;
		}
		public static void LoadMusicExtArray()
		{
			gf.TotalMediaFileExt = 0;
			gf.LoadMusicExtArray("AudioExtensions.txt", gf.MediaBackgroundStyle.Audio);
			gf.LoadMusicExtArray("VideoExtensions.txt", gf.MediaBackgroundStyle.Video);
		}
		public static void LoadMusicExtArray(string InFile, gf.MediaBackgroundStyle InMediaType)
		{
			if (InMediaType != gf.MediaBackgroundStyle.Video)
			{
				InMediaType = gf.MediaBackgroundStyle.Audio;
			}
			string text = gf.RootEasiSlidesDir + "Admin\\Database\\" + InFile;
			if (!File.Exists(text))
			{
				if (File.Exists(Application.StartupPath + "\\Sys\\" + InFile))
				{
					try
					{
						File.Copy(Application.StartupPath + "\\Sys\\" + InFile, text);
					}
					catch
					{
						gf.CreateNewFile(text, gf.FileContentsType.Ascii_Rtf);
					}
				}
				else
				{
					gf.CreateNewFile(text, gf.FileContentsType.Ascii_Rtf);
				}
			}
			StreamReader streamReader = File.OpenText(text);
			string text2 = "";
			while ((text2 = streamReader.ReadLine()) != null)
			{
				text2 = gf.TrimEnd(text2);
				if (text2 != "")
				{
					if (gf.TotalMediaFileExt < 3000)
					{
						if (gf.ValidateMusicExt(ref text2, false))
						{
							gf.MediaFileExtension[gf.TotalMediaFileExt, 0] = text2.ToLower();
							gf.MediaFileExtension[gf.TotalMediaFileExt, 1] = InMediaType.ToString();
							gf.TotalMediaFileExt++;
						}
					}
				}
			}
			streamReader.Close();
		}
		public static bool ValidateMusicExt(ref string InExtension, bool ShowMessage)
		{
			bool result;
			if (!gf.ValidateDirNameFormat(InExtension, ShowMessage ? "Music File Extension" : ""))
			{
				result = false;
			}
			else
			{
				InExtension = gf.Trim(InExtension);
				string text = "";
				for (int i = 0; i < InExtension.Length; i++)
				{
					if (InExtension[i] != '.')
					{
						text += gf.Mid(InExtension, i, 1);
					}
				}
				if (text[0] != '.')
				{
					text = "." + text;
				}
				InExtension = text;
				result = true;
			}
			return result;
		}
		public static string GetOpenFileDialogMediaString()
		{
			string text = gf.GetOpenFileDialogMediaString(gf.MediaBackgroundStyle.None);
			string text2 = gf.GetOpenFileDialogMediaString(gf.MediaBackgroundStyle.Audio);
			string text3 = gf.GetOpenFileDialogMediaString(gf.MediaBackgroundStyle.Video);
			string str = "All Files (*.*)|*.*";
			text = ((text != "") ? (text + "|") : "");
			text2 = ((text2 != "") ? (text2 + "|") : "");
			text3 = ((text3 != "") ? (text3 + "|") : "");
			return text + text2 + text3 + str;
		}
		public static string GetOpenFileDialogMediaString(gf.MediaBackgroundStyle InMediaType)
		{
			string result;
			if (gf.TotalMediaFileExt == 0)
			{
				result = "";
			}
			else
			{
				string str = "";
				string text = "";
				switch (InMediaType)
				{
				case gf.MediaBackgroundStyle.Audio:
					str = "Audio Files (";
					break;
				case gf.MediaBackgroundStyle.Video:
					str = "Video Files (";
					break;
				}
				bool flag = true;
				for (int i = 0; i < gf.TotalMediaFileExt; i++)
				{
					if (InMediaType == gf.MediaBackgroundStyle.None || gf.MediaFileExtension[i, 1] == InMediaType.ToString())
					{
						str = str + (flag ? "" : ",") + "*" + gf.MediaFileExtension[i, 0];
						text = text + (flag ? "" : ";") + "*" + gf.MediaFileExtension[i, 0];
						flag = false;
					}
				}
				if (flag)
				{
					result = "";
				}
				else
				{
					if (InMediaType == gf.MediaBackgroundStyle.None)
					{
						str = "Media Files (all types)";
					}
					else
					{
						str += ")";
					}
					result = str + "|" + text;
				}
			}
			return result;
		}
		public static bool ValidateDir(string FDir, bool CreateDir)
		{
			string text = gf.Trim(FDir);
			if (text != "")
			{
				if (gf.Right(text, 1) != "\\")
				{
					text += "\\";
				}
			}
			return Directory.Exists(text) || (CreateDir && gf.MakeDir(text));
		}
		public static bool ValidateDirNameFormat(string InString)
		{
			return gf.ValidateDirNameFormat(InString, "");
		}
		public static bool ValidateDirNameFormat(string InString, string Heading)
		{
			bool result;
			if (InString.Contains("\\") || InString.Contains("/") || InString.Contains(":") || InString.Contains("*") || InString.Contains("?") || InString.Contains("\"") || InString.Contains("<") || InString.Contains(">") || InString.Contains("|"))
			{
				if (Heading != "")
				{
					MessageBox.Show(Heading + " must not contain the characters: \\ / : * ? \" < > |");
				}
				result = false;
			}
			else
			{
				result = true;
			}
			return result;
		}
		public static string CorrectDirNameFormat(string InString)
		{
			InString = InString.Replace("\\", "");
			InString = InString.Replace("/", "");
			InString = InString.Replace(":", "");
			InString = InString.Replace("*", "");
			InString = InString.Replace("?", "");
			InString = InString.Replace("\"", "");
			InString = InString.Replace("<", "");
			InString = InString.Replace(">", "");
			InString = InString.Replace("|", "");
			return InString;
		}
		public static void LoadFolderNamesArray()
		{
			gf.ValidateDefaultFolders();
			string fullSearchString = "select * from FOLDER where FolderNo >=0 and FolderNo < " + gf.ObjToString(41);
			Recordset recordSet = gf.GetRecordSet(gf.ConnectStringMainDB, fullSearchString);
			if (recordSet != null && !recordSet.EOF)
			{
				recordSet.MoveFirst();
				while (!recordSet.EOF)
				{
					int dataInt = gf.GetDataInt(recordSet, "FolderNo");
					gf.FolderName[dataInt] = gf.GetDataString(recordSet, "name");
					gf.FolderUse[dataInt] = gf.GetDataInt(recordSet, "Use");
					gf.FolderGroupStyle[dataInt] = (gf.SortBy)gf.GetDataInt(recordSet, "GroupStyle");
					gf.FolderLyricsHeading[dataInt, 0] = gf.GetDataString(recordSet, "PreChorusHeading");
					gf.FolderLyricsHeading[dataInt, 1] = gf.GetDataString(recordSet, "ChorusHeading");
					gf.FolderLyricsHeading[dataInt, 2] = gf.GetDataString(recordSet, "BridgeHeading");
					gf.FolderLyricsHeading[dataInt, 3] = gf.GetDataString(recordSet, "EndingHeading");
					gf.FolderHeadingPercentSize[dataInt] = gf.ObjToInt(gf.GetDataString(recordSet, "HeadingSize"));
					if (gf.FolderHeadingPercentSize[dataInt] < 0 | gf.FolderHeadingPercentSize[dataInt] > 150)
					{
						gf.FolderHeadingPercentSize[dataInt] = 100;
					}
					string text = gf.GetDataString(recordSet, "HeadingOption");
					if (text == "")
					{
						text = gf.ObjToString(gf.HeadingFormat.AsRegion1Plus);
					}
					gf.FolderHeadingOption[dataInt] = gf.ObjToInt(text);
					if (gf.FolderHeadingOption[dataInt] < 0 | gf.FolderHeadingOption[dataInt] > 2)
					{
						gf.FolderHeadingOption[dataInt] = gf.ObjToInt(gf.HeadingFormat.AsRegion1Plus);
					}
					string text2 = gf.GetDataString(recordSet, "BIUHeading");
					if (text2 == "")
					{
						text2 = "4";
					}
					gf.FolderHeadingFontBold[dataInt, 0] = gf.GetBitValue(gf.ObjToInt(text2), 1);
					gf.FolderHeadingFontItalic[dataInt, 0] = gf.GetBitValue(gf.ObjToInt(text2), 2);
					gf.FolderHeadingFontUnderline[dataInt, 0] = gf.GetBitValue(gf.ObjToInt(text2), 3);
					gf.FolderHeadingFontBold[dataInt, 1] = gf.GetBitValue(gf.ObjToInt(text2), 4);
					gf.FolderHeadingFontItalic[dataInt, 1] = gf.GetBitValue(gf.ObjToInt(text2), 5);
					gf.FolderHeadingFontUnderline[dataInt, 1] = gf.GetBitValue(gf.ObjToInt(text2), 6);
					gf.ShowLineSpacing[dataInt, 0] = gf.GetDataDouble(recordSet, "LineSpacing");
					if (gf.ShowLineSpacing[dataInt, 0] < 0.5 | gf.ShowLineSpacing[dataInt, 0] > 2.0)
					{
						gf.ShowLineSpacing[dataInt, 0] = 1.0;
					}
					gf.ShowLineSpacing[dataInt, 1] = gf.GetDataDouble(recordSet, "LineSpacing2");
					if (gf.ShowLineSpacing[dataInt, 1] < 0.5 | gf.ShowLineSpacing[dataInt, 1] > 2.0)
					{
						gf.ShowLineSpacing[dataInt, 1] = 1.0;
					}
					gf.ShowLeftMargin[dataInt] = 2;
					gf.ShowLeftMargin[dataInt] = gf.GetDataInt(recordSet, "LMargin");
					if (gf.ShowLeftMargin[dataInt] < 0 | gf.ShowLeftMargin[dataInt] > 40)
					{
						gf.ShowLeftMargin[dataInt] = 2;
					}
					gf.ShowRightMargin[dataInt] = 2;
					gf.ShowRightMargin[dataInt] = gf.GetDataInt(recordSet, "RMargin");
					if (gf.ShowRightMargin[dataInt] < 0 | gf.ShowRightMargin[dataInt] > 40)
					{
						gf.ShowRightMargin[dataInt] = 2;
					}
					gf.ShowBottomMargin[dataInt] = 0;
					gf.ShowBottomMargin[dataInt] = gf.GetDataInt(recordSet, "BMargin");
					if (gf.ShowBottomMargin[dataInt] < 0 | gf.ShowBottomMargin[dataInt] > 100)
					{
						gf.ShowBottomMargin[dataInt] = 0;
					}
					gf.ShowFontSize[dataInt, 0] = gf.ObjToInt(gf.GetDataString(recordSet, "Size0"));
					if (gf.ShowFontSize[dataInt, 0] < 1 | gf.ShowFontSize[dataInt, 0] > 100)
					{
						gf.ShowFontSize[dataInt, 0] = 37;
					}
					gf.ShowFontBold[dataInt, 0] = gf.GetBitValue(gf.GetDataInt(recordSet, "BIU0"), 1);
					gf.ShowFontItalic[dataInt, 0] = gf.GetBitValue(gf.GetDataInt(recordSet, "BIU0"), 2);
					gf.ShowFontUnderline[dataInt, 0] = gf.GetBitValue(gf.GetDataInt(recordSet, "BIU0"), 3);
					gf.ShowFontBold[dataInt, 2] = gf.GetBitValue(gf.GetDataInt(recordSet, "BIU0"), 4);
					gf.ShowFontItalic[dataInt, 2] = gf.GetBitValue(gf.GetDataInt(recordSet, "BIU0"), 5);
					gf.ShowFontUnderline[dataInt, 2] = gf.GetBitValue(gf.GetDataInt(recordSet, "BIU0"), 6);
					gf.ShowFontRTL[dataInt, 0] = gf.GetBitValue(gf.GetDataInt(recordSet, "BIU0"), 7);
					gf.ShowFontName[dataInt, 0] = gf.GetDataString(recordSet, "FontName0");
					if (gf.ShowFontName[dataInt, 0] == "")
					{
						gf.ShowFontName[dataInt, 0] = "Microsoft Sans Serif";
					}
					gf.ShowFontVPosition[dataInt, 0] = gf.ObjToInt(gf.GetDataString(recordSet, "Vpos0"));
					if (gf.ShowFontVPosition[dataInt, 0] < 0 | gf.ShowFontVPosition[dataInt, 0] > 100)
					{
						gf.ShowFontVPosition[dataInt, 0] = 0;
					}
					gf.ShowFontSize[dataInt, 1] = gf.ObjToInt(gf.GetDataString(recordSet, "Size1"));
					if (gf.ShowFontSize[dataInt, 1] < 1 | gf.ShowFontSize[dataInt, 1] > 100)
					{
						gf.ShowFontSize[dataInt, 1] = 37;
					}
					gf.ShowFontBold[dataInt, 1] = gf.GetBitValue(gf.GetDataInt(recordSet, "BIU1"), 1);
					gf.ShowFontItalic[dataInt, 1] = gf.GetBitValue(gf.GetDataInt(recordSet, "BIU1"), 2);
					gf.ShowFontUnderline[dataInt, 1] = gf.GetBitValue(gf.GetDataInt(recordSet, "BIU1"), 3);
					gf.ShowFontBold[dataInt, 3] = gf.GetBitValue(gf.GetDataInt(recordSet, "BIU1"), 4);
					gf.ShowFontItalic[dataInt, 3] = gf.GetBitValue(gf.GetDataInt(recordSet, "BIU1"), 5);
					gf.ShowFontUnderline[dataInt, 3] = gf.GetBitValue(gf.GetDataInt(recordSet, "BIU1"), 6);
					gf.ShowFontRTL[dataInt, 1] = gf.GetBitValue(gf.GetDataInt(recordSet, "BIU1"), 7);
					gf.ShowFontName[dataInt, 1] = gf.GetDataString(recordSet, "FontName1");
					if (gf.ShowFontName[dataInt, 1] == "")
					{
						gf.ShowFontName[dataInt, 1] = "Microsoft Sans Serif";
					}
					gf.ShowFontVPosition[dataInt, 1] = gf.ObjToInt(gf.GetDataString(recordSet, "Vpos1"));
					if (gf.ShowFontVPosition[dataInt, 1] < gf.ShowFontVPosition[dataInt, 0] | gf.ShowFontVPosition[dataInt, 1] > 100)
					{
						gf.ShowFontVPosition[dataInt, 1] = gf.ShowFontVPosition[dataInt, 0] + (100 - gf.ShowFontVPosition[dataInt, 0]) / 2;
					}
					recordSet.MoveNext();
				}
			}
		}
		public static void ComputeShowLineSpacing()
		{
			for (int i = 0; i < 41; i++)
			{
				gf.MainFontSpacingFactor[i, 0] = gf.ShowLineSpacing[i, 0] + 0.05;
				gf.MainFontSpacingFactor[i, 1] = gf.ShowLineSpacing[i, 1] + 0.05;
			}
		}
		public static void LoadLicAdminDetails()
		{
			gf.LicAdminEnforceDisplay = (gf.ObjToInt(gf.GetRegValue("config", "licEnforceDisplay", 1)) > 0);
			gf.LicAdminNoSymbol = gf.GetRegValue("config", "licNoSym", "#");
			gf.LicAdmin_List[0, 0] = "1";
			gf.LicAdmin_List[1, 0] = "None";
			gf.LicAdmin_List[2, 0] = "Public Domain";
			gf.LicAdmin_List[3, 0] = "CCLI";
			for (int i = 4; i < 9; i++)
			{
				gf.LicAdmin_List[i, 0] = "";
			}
			string fullSearchString = "select * from LICENCE where Ref >=4 and Ref < " + gf.ObjToString(9);
			Recordset recordSet = gf.GetRecordSet(gf.ConnectStringMainDB, fullSearchString);
			if (recordSet != null && !recordSet.EOF)
			{
				recordSet.MoveFirst();
				while (!recordSet.EOF)
				{
					int i = gf.GetDataInt(recordSet, "Ref");
					gf.LicAdmin_List[i, 0] = gf.Trim(gf.GetDataString(recordSet, "ADMINISTRATOR"));
					recordSet.MoveNext();
				}
			}
			gf.LicAdmin_List[1, 1] = "";
			gf.LicAdmin_List[2, 1] = "Public Domain";
			gf.LicAdmin_List[3, 1] = gf.Trim(gf.GetRegValue("config", "licCCLI_no", ""));
			gf.LicAdmin_List[4, 1] = gf.Trim(gf.GetRegValue("config", "lic4_no", ""));
			gf.LicAdmin_List[5, 1] = gf.Trim(gf.GetRegValue("config", "lic5_no", ""));
			gf.LicAdmin_List[6, 1] = gf.Trim(gf.GetRegValue("config", "lic6_no", ""));
			gf.LicAdmin_List[7, 1] = gf.Trim(gf.GetRegValue("config", "lic7_no", ""));
			gf.LicAdmin_List[8, 1] = gf.Trim(gf.GetRegValue("config", "lic8_no", ""));
			gf.LicAdmin_List[1, 2] = "";
			gf.LicAdmin_List[2, 2] = "Public Domain";
			for (int i = 3; i < 9; i++)
			{
				if (gf.LicAdmin_List[i, 0] == "" | gf.LicAdmin_List[i, 1] == "")
				{
					gf.LicAdmin_List[i, 2] = "";
				}
				else
				{
					gf.LicAdmin_List[i, 2] = gf.LicAdmin_List[i, 0] + gf.LicAdminNoSymbol + gf.LicAdmin_List[i, 1];
				}
			}
			gf.LicAdmin_List[0, 1] = gf.LicAdmin_List[1, 1];
			gf.LicAdmin_List[0, 2] = gf.LicAdmin_List[1, 2];
		}
		public static void SaveConfigSettings()
		{
			gf.SaveRegValue("config", "root_directory", gf.RootEasiSlidesDir);
			gf.SaveRegValue("config", "current_session", gf.CurSession);
			gf.SaveRegValue("config", "current_praisebook", gf.CurPraiseBook);
			gf.SaveRegValue("config", "export_dir", gf.ExportToDir);
			gf.SaveRegValue("config", "import_dir", gf.ImportFromDir);
			gf.SaveRegValue("config", "praiseoutput_dir", gf.PraiseOutputDir);
			gf.SaveRegValue("config", "media_dir", gf.MediaDir);
			gf.SaveOptionsData();
			gf.SaveLicenceConfigSettings();
			gf.SaveFoldersSettings();
		}
		public static void SaveFoldersSettings()
		{
			int num = 0;
			if (gf.ValidateDefaultFolders(0))
			{
				try
				{
					Database daoDb = gf.GetDaoDb(gf.ConnectStringMainDB);
					Recordset recordset = null;
					for (int i = 1; i < 41; i++)
					{
						num = i;
						if (gf.FolderName[i] != "")
						{
							string fullSearchString = "select * from Folder where FolderNo=" + i.ToString();
							recordset = gf.GetRecordSet(daoDb, fullSearchString);
							recordset.Edit();
							recordset.Fields["name"].Value = gf.FolderName[i];
							recordset.Fields["Use"].Value = gf.FolderUse[i];
							recordset.Fields["GroupStyle"].Value = gf.FolderGroupStyle[i];
							recordset.Fields["PreChorusHeading"].Value = gf.FolderLyricsHeading[i, 0];
							recordset.Fields["ChorusHeading"].Value = gf.FolderLyricsHeading[i, 1];
							recordset.Fields["BridgeHeading"].Value = gf.FolderLyricsHeading[i, 2];
							recordset.Fields["EndingHeading"].Value = gf.FolderLyricsHeading[i, 3];
							recordset.Fields["BIUHeading"].Value = gf.FolderHeadingFontBold[i, 0] + gf.FolderHeadingFontItalic[i, 0] * 2 + gf.FolderHeadingFontUnderline[i, 0] * 4 + gf.FolderHeadingFontBold[i, 1] * 8 + gf.FolderHeadingFontItalic[i, 1] * 16 + gf.FolderHeadingFontUnderline[i, 1] * 32;
							recordset.Fields["HeadingSize"].Value = gf.FolderHeadingPercentSize[i];
							recordset.Fields["HeadingOption"].Value = gf.FolderHeadingOption[i];
							recordset.Fields["LineSpacing"].Value = gf.ShowLineSpacing[i, 0];
							recordset.Fields["LineSpacing2"].Value = gf.ShowLineSpacing[i, 1];
							recordset.Fields["BIU0"].Value = gf.ShowFontBold[i, 0] + gf.ShowFontItalic[i, 0] * 2 + gf.ShowFontUnderline[i, 0] * 4 + gf.ShowFontBold[i, 2] * 8 + gf.ShowFontItalic[i, 2] * 16 + gf.ShowFontUnderline[i, 2] * 32 + gf.ShowFontRTL[i, 0] * 64;
							recordset.Fields["Size0"].Value = gf.ShowFontSize[i, 0];
							recordset.Fields["FontName0"].Value = gf.ShowFontName[i, 0];
							recordset.Fields["Vpos0"].Value = gf.ShowFontVPosition[i, 0];
							recordset.Fields["BIU1"].Value = gf.ShowFontBold[i, 1] + gf.ShowFontItalic[i, 1] * 2 + gf.ShowFontUnderline[i, 1] * 4 + gf.ShowFontBold[i, 3] * 8 + gf.ShowFontItalic[i, 3] * 16 + gf.ShowFontUnderline[i, 3] * 32 + gf.ShowFontRTL[i, 1] * 64;
							recordset.Fields["Size1"].Value = gf.ShowFontSize[i, 1];
							recordset.Fields["FontName1"].Value = gf.ShowFontName[i, 1];
							recordset.Fields["Vpos1"].Value = gf.ShowFontVPosition[i, 1];
							recordset.Fields["LMargin"].Value = gf.ShowLeftMargin[i];
							recordset.Fields["RMargin"].Value = gf.ShowRightMargin[i];
							recordset.Fields["BMargin"].Value = gf.ShowBottomMargin[i];
							recordset.Update(1, false);
							recordset.Close();
						}
					}
					if (recordset != null)
					{
					}
				}
				catch
				{
					MessageBox.Show("Error: Cannot Save Folder Settings for Folder Index: " + num.ToString());
				}
			}
		}
		public static void SaveFoldersSettings_ADO()
		{
			if (gf.ValidateDefaultFolders(0))
			{
				OleDbConnection oleDbConnection = new OleDbConnection(gf.ConnectStringMainDB);
				try
				{
					string selectCommandText = "select * from FOLDER where FolderNo >=1 and FolderNo < " + gf.ObjToString(41);
					OleDbDataAdapter oleDbDataAdapter = new OleDbDataAdapter(selectCommandText, oleDbConnection);
					DataSet dataSet = new DataSet();
					oleDbDataAdapter.Fill(dataSet);
					DataTable dataTable = dataSet.Tables[0];
					foreach (DataRow dataRow in dataTable.Rows)
					{
						int num = gf.ObjToInt(dataRow["FolderNo"]);
						if (gf.FolderName[num] != "")
						{
							dataRow.BeginEdit();
							dataRow["name"] = gf.FolderName[num];
							dataRow["Use"] = gf.FolderUse[num];
							dataRow["GroupStyle"] = gf.FolderGroupStyle[num];
							dataRow["PreChorusHeading"] = gf.FolderLyricsHeading[num, 0];
							dataRow["ChorusHeading"] = gf.FolderLyricsHeading[num, 1];
							dataRow["BridgeHeading"] = gf.FolderLyricsHeading[num, 2];
							dataRow["EndingHeading"] = gf.FolderLyricsHeading[num, 3];
							dataRow["BIUHeading"] = gf.FolderHeadingFontBold[num, 0] + gf.FolderHeadingFontItalic[num, 0] * 2 + gf.FolderHeadingFontUnderline[num, 0] * 4 + gf.FolderHeadingFontBold[num, 1] * 8 + gf.FolderHeadingFontItalic[num, 1] * 16 + gf.FolderHeadingFontUnderline[num, 1] * 32;
							dataRow["HeadingSize"] = gf.FolderHeadingPercentSize[num];
							dataRow["HeadingOption"] = gf.FolderHeadingOption[num];
							dataRow["LineSpacing"] = gf.ShowLineSpacing[num, 0];
							dataRow["LineSpacing2"] = gf.ShowLineSpacing[num, 1];
							dataRow["BIU0"] = gf.ShowFontBold[num, 0] + gf.ShowFontItalic[num, 0] * 2 + gf.ShowFontUnderline[num, 0] * 4;
							dataRow["Size0"] = gf.ShowFontSize[num, 0];
							dataRow["FontName0"] = gf.ShowFontName[num, 0];
							dataRow["Vpos0"] = gf.ShowFontVPosition[num, 0];
							dataRow["BIU1"] = gf.ShowFontBold[num, 1] + gf.ShowFontItalic[num, 1] * 2 + gf.ShowFontUnderline[num, 1] * 4;
							dataRow["Size1"] = gf.ShowFontSize[num, 1];
							dataRow["FontName1"] = gf.ShowFontName[num, 1];
							dataRow["Vpos1"] = gf.ShowFontVPosition[num, 1];
							dataRow["LMargin"] = gf.ShowLeftMargin[num];
							dataRow["RMargin"] = gf.ShowRightMargin[num];
							dataRow["BMargin"] = gf.ShowBottomMargin[num];
							dataRow.EndEdit();
							dataRow.AcceptChanges();
						}
					}
				}
				catch
				{
				}
				finally
				{
					if (oleDbConnection.State == ConnectionState.Open)
					{
						oleDbConnection.Close();
					}
				}
			}
		}
		public static void SaveLicenceConfigSettings()
		{
			gf.SaveRegValue("config", "licCCLI_no", gf.LicAdmin_List[3, 1]);
			gf.SaveRegValue("config", "lic4_no", gf.LicAdmin_List[4, 1]);
			gf.SaveRegValue("config", "lic5_no", gf.LicAdmin_List[5, 1]);
			gf.SaveRegValue("config", "lic6_no", gf.LicAdmin_List[6, 1]);
			gf.SaveRegValue("config", "lic7_no", gf.LicAdmin_List[7, 1]);
			gf.SaveRegValue("config", "lic8_no", gf.LicAdmin_List[8, 1]);
			gf.SaveRegValue("config", "licNoSym", gf.LicAdminNoSymbol);
			gf.SaveRegValue("config", "licEnforceDisplay", gf.LicAdminEnforceDisplay ? 1 : 0);
		}
		public static void SaveOptionsData()
		{
			gf.SaveRegValue("options", "PrinterSpaces", gf.PB_PrinterSpaces);
			gf.SaveRegValue("options", "UseSongNumbers", gf.UseSongNumbers ? 1 : 0);
			gf.SaveRegValue("options", "BibleMaxSelectVerses", gf.HB_MaxVersesSelection);
			gf.SaveRegValue("options", "BibleMaxAdhocVersesSelection", gf.HB_MaxAdhocVersesSelection);
			gf.SaveRegValue("options", "BibleShowVerses", 1);
			gf.SaveRegValue("options", "PowerpointMaxFiles", gf.PP_MaxFiles);
			gf.SaveRegValue("options", "AutoTextOverflow", gf.AutoTextOverflow ? 1 : 0);
			gf.SaveRegValue("options", "UseLargestFontSize", gf.UseLargestFontSize ? 1 : 0);
			gf.SaveRegValue("options", "UsePowerpointTab", gf.UsePowerpointTab ? 1 : 0);
			gf.SaveRegValue("options", "NoPowerpointPanelOverlay", gf.NoPowerpointPanelOverlay ? 1 : 0);
			gf.SaveRegValue("options", "UseMediaTab", gf.UseMediaTab ? 1 : 0);
			gf.SaveRegValue("options", "ShowLyricsMonitorAlertBox", gf.ShowLyricsMonitorAlertBox ? 1 : 0);
			gf.SaveRegValue("options", "NoMediaPanelOverlay", gf.NoMediaPanelOverlay ? 1 : 0);
			gf.SaveRegValue("options", "RotateGap", gf.ShowRotateGap);
			gf.SaveRegValue("options", "AdvanceNextItem", gf.AdvanceNextItem ? 1 : 0);
			gf.SaveRegValue("options", "LineBetweenRegions", gf.LineBetweenRegions ? 1 : 0);
			gf.SaveRegValue("options", "GapItemOption", (int)gf.GapItemOption);
			gf.SaveRegValue("options", "GapItemLogoFile", gf.GapItemLogoFile);
			gf.SaveRegValue("options", "GapItemUseFade", gf.GapItemUseFade ? 1 : 0);
			gf.SaveRegValue("options", "WordWrapLeftAlignIndent", gf.WordWrapLeftAlignIndent ? 1 : 0);
			gf.SaveRegValue("options", "WordWrapIgnoreStartSpaces", gf.WordWrapIgnoreStartSpaces);
			gf.SaveRegValue("options", "AutoRotateOn", gf.AutoRotateOn ? 1 : 0);
			gf.SaveRegValue("options", "AutoRotateStyle", gf.AutoRotateStyle);
			gf.SaveRegValue("options", "NotationFontFactor", (int)(gf.NotationFontFactor * 100.0));
			gf.SaveRegValue("options", "ExternalListing", gf.PowerpointListingStyle);
			gf.SaveRegValue("options", "KeyBoardOption", gf.KeyBoardOption);
			gf.SaveRegValue("options", "OutputmonitorNumber", gf.OutputMonitorNumber);
			gf.SaveRegValue("options", "LyricsMonitorNumber", gf.LyricsMonitorNumber);
			gf.SaveRegValue("options", "PreviewAreaShowNotations", gf.PreviewArea_ShowNotations ? 1 : 0);
			gf.SaveRegValue("options", "PreviewAreaLineBetweenScreens", gf.PreviewArea_LineBetweenScreens ? 1 : 0);
			gf.SaveRegValue("options", "PreviewAreaFontSize", gf.PreviewArea_FontSize);
			gf.SaveRegValue("options", "ParentalAlertHeading", gf.ParentalAlertHeading);
			gf.SaveRegValue("options", "ParentalAlertDuration", gf.ParentalAlertDuration);
			gf.SaveRegValue("options", "ParentalAlertTextColour", gf.ParentalAlertTextColour.ToArgb());
			gf.SaveRegValue("options", "ParentalAlertBackColour", gf.ParentalAlertBackColour.ToArgb());
			gf.SaveRegValue("options", "ParentalAlertTextAlign", gf.ParentalAlertTextAlign);
			gf.SaveRegValue("options", "ParentalAlertVerticalAlign", gf.ParentalAlertVerticalAlign);
			int value = (gf.ParentalAlertScroll ? 1 : 0) + (gf.ParentalAlertFlash ? 1 : 0) * 2 + (gf.ParentalAlertTransparent ? 1 : 0) * 4;
			gf.SaveRegValue("options", "ParentalAlertStyle", value);
			gf.SaveRegValue("options", "ParentalAlertFontName", gf.ParentalAlertFontName);
			gf.SaveRegValue("options", "ParentalAlertFontSize", gf.ParentalAlertFontSize);
			gf.SaveRegValue("options", "ParentalAlertFontFormat", gf.ParentalAlertFontFormat);
			gf.SaveRegValue("options", "MessageAlertDuration", gf.MessageAlertDuration);
			gf.SaveRegValue("options", "MessageAlertTextAlign", gf.MessageAlertTextAlign);
			gf.SaveRegValue("options", "MessageAlertVerticalAlign", gf.MessageAlertVerticalAlign);
			gf.SaveRegValue("options", "MessageAlertTextColour", gf.MessageAlertTextColour.ToArgb());
			gf.SaveRegValue("options", "MessageAlertBackColour", gf.MessageAlertBackColour.ToArgb());
			value = (gf.MessageAlertScroll ? 1 : 0) + (gf.MessageAlertFlash ? 1 : 0) * 2 + (gf.MessageAlertTransparent ? 1 : 0) * 4;
			gf.SaveRegValue("options", "MessageAlertStyle", value);
			gf.SaveRegValue("options", "MessageAlertFontName", gf.MessageAlertFontName);
			gf.SaveRegValue("options", "MessageAlertFontSize", gf.MessageAlertFontSize);
			gf.SaveRegValue("options", "MessageAlertFontFormat", gf.MessageAlertFontFormat);
			gf.SaveRegValue("options", "ReferenceAlertDuration", gf.ReferenceAlertDuration);
			gf.SaveRegValue("options", "ReferenceAlertTextAlign", gf.ReferenceAlertTextAlign);
			gf.SaveRegValue("options", "ReferenceAlertVerticalAlign", gf.ReferenceAlertVerticalAlign);
			gf.SaveRegValue("options", "ReferenceAlertTextColour", gf.ReferenceAlertTextColour.ToArgb());
			gf.SaveRegValue("options", "ReferenceAlertBackColour", gf.ReferenceAlertBackColour.ToArgb());
			value = (gf.ReferenceAlertScroll ? 1 : 0) + (gf.ReferenceAlertFlash ? 1 : 0) * 2 + (gf.ReferenceAlertTransparent ? 1 : 0) * 4;
			gf.SaveRegValue("options", "ReferenceAlertStyle", value);
			gf.SaveRegValue("options", "ReferenceAlertFontName", gf.ReferenceAlertFontName);
			gf.SaveRegValue("options", "ReferenceAlertFontSize", gf.ReferenceAlertFontSize);
			gf.SaveRegValue("options", "ReferenceAlertFontFormat", gf.ReferenceAlertFontFormat);
			gf.SaveRegValue("options", "ReferenceAlertUsePick", gf.ReferenceAlertUsePick ? 1 : 0);
			gf.SaveRegValue("options", "ReferenceAlertBlankIfPickNotFound", gf.ReferenceAlertBlankIfPickNotFound ? 1 : 0);
			gf.SaveRegValue("options", "ReferenceAlertSource", gf.ReferenceAlertSource);
			gf.SaveRegValue("options", "ReferenceAlertPickName", gf.ReferenceAlertPickName);
			gf.SaveRegValue("options", "ReferenceAlertPickSubstitute", gf.ReferenceAlertPickSubstitute);
			gf.SaveRegValue("options", "ReferenceAlertPickSeparator", gf.ReferenceAlertPickSeparator);
			gf.SaveRegValue("options", "FocusedBackColour", gf.FocusedTextRegionColour.ToArgb());
			gf.SaveRegValue("options", "SelectedSlideTextColour", gf.TextRegionSlideTextColour.ToArgb());
			gf.SaveRegValue("options", "SelectedSlideBackColour", gf.TextRegionSlideBackColour.ToArgb());
			gf.SaveRegValue("options", "UseFocusedBackColour", gf.UseFocusedTextRegionColour ? 1 : 0);
			gf.SaveRegValue("options", "JumpToA", gf.JumpToA);
			gf.SaveRegValue("options", "JumpToB", gf.JumpToB);
			gf.SaveRegValue("options", "JumpToC", gf.JumpToC);
			gf.SaveRegValue("options", "FindItemInTitle", gf.FindItemInTitle ? 1 : 0);
			gf.SaveRegValue("options", "FindItemInContents", gf.FindItemInContents ? 1 : 0);
			gf.SaveRegValue("options", "FindItemInSongNumber", gf.FindItemInSongNumber ? 1 : 0);
			gf.SaveRegValue("options", "FindItemInBookRef", gf.FindItemInBookRef ? 1 : 0);
			gf.SaveRegValue("options", "FindItemInUserRef", gf.FindItemInUserRef ? 1 : 0);
			gf.SaveRegValue("options", "FindItemInLicAdmin", gf.FindItemInLicAdmin ? 1 : 0);
			gf.SaveRegValue("options", "FindItemInWriter", gf.FindItemInWriter ? 1 : 0);
			gf.SaveRegValue("options", "FindItemInCopyright", gf.FindItemInCopyright ? 1 : 0);
			gf.SaveRegValue("options", "FindItemInTitle", gf.FindItemInTitle ? 1 : 0);
			gf.SaveRegValue("options", "FindItemUseDates", gf.FindItemUseDates ? 1 : 0);
			gf.SaveRegValue("options", "FindItemDateFrom", gf.FindItemDateFrom.ToString());
			gf.SaveRegValue("options", "FindItemDateTo", gf.FindItemDateTo.ToString());
			gf.SaveRegValue("options", "OutlineFontSizeThreshold", gf.OutlineFontSizeThreshold);
			gf.SaveRegValue("monitors", "AlwaysTryDualMonitor", gf.DMAlwaysUse ? 1 : 0);
			gf.SaveRegValue("monitors", "DualMonitorOption", gf.DMOption);
			gf.SaveRegValue("monitors", "DualMonitorOptionCustomLeft", gf.DMOption1Left);
			gf.SaveRegValue("monitors", "DualMonitorOptionCustomTop", gf.DMOption1Top);
			gf.SaveRegValue("monitors", "DualMonitorOptionCustomWidth", gf.DMOption1Width);
			gf.SaveRegValue("monitors", "DualMonitorOptionCustomAsSingle", gf.DMOption1AsSingleMonitor ? 1 : 0);
			gf.SaveRegValue("monitors", "DisableSreenSaver", gf.DisableSreenSaver ? 1 : 0);
			gf.SaveRegValue("monitors", "VideoSize", gf.VideoSize);
			gf.SaveRegValue("monitors", "VideoVAlign", gf.VideoVAlign);
			gf.SaveRegValue("monitors", "AlwaysTrySecondaryLyricsMonitor", gf.LMAlwaysUse ? 1 : 0);
			gf.SaveRegValue("monitors", "LyricsMonitorOption", gf.LMOption);
			gf.SaveRegValue("monitors", "LyricsMonitorOptionCustomLeft", gf.LMOption1Left);
			gf.SaveRegValue("monitors", "LyricsMonitorOptionCustomTop", gf.LMOption1Top);
			gf.SaveRegValue("monitors", "LyricsMonitorOptionCustomWidth", gf.LMOption1Width);
			gf.SaveRegValue("monitors", "LyricsMonitorTextColour", gf.LMTextColour.ToArgb());
			gf.SaveRegValue("monitors", "LyricsMonitorHighlightColour", gf.LMHighlightColour.ToArgb());
			gf.SaveRegValue("monitors", "LyricsMonitorBackColour", gf.LMBackColour.ToArgb());
			gf.SaveRegValue("monitors", "LyricsMonitorShowNotations", gf.LMShowNotations ? 1 : 0);
			gf.SaveRegValue("monitors", "LyricsMonitorFontSize", gf.LMMainFontSize);
			gf.SaveRegValue("monitors", "LyricsMonitorNotationsFontSize", gf.LMNotationsFontSize);
			gf.SaveRegValue("options", "LyricsMonitorFontFormat", gf.LMFontFormat);
			gf.SaveRegValue("monitors", "LiveCamNumber", gf.LiveCamNumber);
			gf.SaveRegValue("monitors", "LiveCamVolume", gf.LiveCamVolume);
			gf.SaveRegValue("monitors", "LiveCamBalance", gf.LiveCamBalance);
			gf.SaveRegValue("monitors", "LiveCamWidescreen", gf.LiveCamWidescreen ? 1 : 0);
			gf.SaveRegValue("monitors", "LiveCamNoPanelOverlay", gf.LiveCamNoPanelOverlay ? 1 : 0);
			gf.SaveRegValue("monitors", "LiveCamMute", gf.LiveCamMute ? 1 : 0);
		}
		public static bool ValidateDefaultFolders()
		{
			return gf.ValidateDefaultFolders(0);
		}
		public static bool ValidateDefaultFolders(int CheckColumns)
		{
			bool result;
			if (!gf.ValidateDB(gf.DatabaseType.Songs))
			{
				result = false;
			}
			else
			{
				for (int i = 0; i < 41; i++)
				{
					gf.ResetFolder(i, "", gf.ConnectStringMainDB);
				}
				result = true;
			}
			return result;
		}
		public static void LoadSongKeyCapoTiming(ref ComboBox SongCapo, ref ComboBox SongKey, ref ComboBox SongTiming)
		{
			SongCapo.Items.Clear();
			SongCapo.Items.Add("");
			SongCapo.Items.Add("Capo 0");
			SongCapo.Items.Add("Capo 1");
			SongCapo.Items.Add("Capo 2");
			SongCapo.Items.Add("Capo 3");
			SongCapo.Items.Add("Capo 4");
			SongCapo.Items.Add("Capo 5");
			SongCapo.Items.Add("Capo 6");
			SongCapo.Items.Add("Capo 7");
			SongCapo.Items.Add("Capo 8");
			SongCapo.Items.Add("Capo 9");
			SongCapo.Items.Add("Capo 10");
			SongCapo.Items.Add("Capo 11");
			SongKey.Items.Clear();
			SongKey.Items.Add("");
			SongKey.Items.Add("A");
			SongKey.Items.Add("B");
			SongKey.Items.Add("C");
			SongKey.Items.Add("D");
			SongKey.Items.Add("E");
			SongKey.Items.Add("F");
			SongKey.Items.Add("G");
			SongKey.Items.Add("Am");
			SongKey.Items.Add("Bm");
			SongKey.Items.Add("Cm");
			SongKey.Items.Add("Dm");
			SongKey.Items.Add("Em");
			SongKey.Items.Add("Fm");
			SongKey.Items.Add("Gm");
			SongKey.Items.Add("Ab");
			SongKey.Items.Add("Bb");
			SongKey.Items.Add("Db");
			SongKey.Items.Add("Eb");
			SongKey.Items.Add("F#");
			SongKey.Items.Add("Bbm");
			SongKey.Items.Add("C#m");
			SongKey.Items.Add("D#m");
			SongKey.Items.Add("F#m");
			SongKey.Items.Add("G#m");
			SongTiming.Items.Clear();
			SongTiming.Items.Add("");
			SongTiming.Items.Add("3/4");
			SongTiming.Items.Add("4/4");
		}
		public static void GenerateMusicKeysList()
		{
			gf.MusicMajorKeys[0] = "G";
			gf.MusicMajorKeys[1] = "Ab";
			gf.MusicMajorKeys[2] = "A";
			gf.MusicMajorKeys[3] = "Bb";
			gf.MusicMajorKeys[4] = "B";
			gf.MusicMajorKeys[5] = "C";
			gf.MusicMajorKeys[6] = "Db";
			gf.MusicMajorKeys[7] = "D";
			gf.MusicMajorKeys[8] = "Eb";
			gf.MusicMajorKeys[9] = "E";
			gf.MusicMajorKeys[10] = "F";
			gf.MusicMajorKeys[11] = "F#";
			gf.MusicMajorKeysFlatSharp[0] = 1;
			gf.MusicMajorKeysFlatSharp[1] = 0;
			gf.MusicMajorKeysFlatSharp[2] = 1;
			gf.MusicMajorKeysFlatSharp[3] = 0;
			gf.MusicMajorKeysFlatSharp[4] = 1;
			gf.MusicMajorKeysFlatSharp[5] = 1;
			gf.MusicMajorKeysFlatSharp[6] = 0;
			gf.MusicMajorKeysFlatSharp[7] = 1;
			gf.MusicMajorKeysFlatSharp[8] = 0;
			gf.MusicMajorKeysFlatSharp[9] = 1;
			gf.MusicMajorKeysFlatSharp[10] = 0;
			gf.MusicMajorKeysFlatSharp[11] = 1;
			gf.MusicMinorKeys[0] = "Gm";
			gf.MusicMinorKeys[1] = "G#m";
			gf.MusicMinorKeys[2] = "Am";
			gf.MusicMinorKeys[3] = "Bbm";
			gf.MusicMinorKeys[4] = "Bm";
			gf.MusicMinorKeys[5] = "Cm";
			gf.MusicMinorKeys[6] = "C#m";
			gf.MusicMinorKeys[7] = "Dm";
			gf.MusicMinorKeys[8] = "D#m";
			gf.MusicMinorKeys[9] = "Em";
			gf.MusicMinorKeys[10] = "Fm";
			gf.MusicMinorKeys[11] = "F#m";
			gf.MusicMinorKeysFlatSharp[0] = 0;
			gf.MusicMinorKeysFlatSharp[1] = 1;
			gf.MusicMinorKeysFlatSharp[2] = 1;
			gf.MusicMinorKeysFlatSharp[3] = 0;
			gf.MusicMinorKeysFlatSharp[4] = 1;
			gf.MusicMinorKeysFlatSharp[5] = 0;
			gf.MusicMinorKeysFlatSharp[6] = 1;
			gf.MusicMinorKeysFlatSharp[7] = 0;
			gf.MusicMinorKeysFlatSharp[8] = 1;
			gf.MusicMinorKeysFlatSharp[9] = 1;
			gf.MusicMinorKeysFlatSharp[10] = 0;
			gf.MusicMinorKeysFlatSharp[11] = 1;
			gf.MusicMajorChords[0, 0] = "G";
			gf.MusicMajorChords[1, 0] = "Ab";
			gf.MusicMajorChords[2, 0] = "A";
			gf.MusicMajorChords[3, 0] = "Bb";
			gf.MusicMajorChords[4, 0] = "B";
			gf.MusicMajorChords[5, 0] = "C";
			gf.MusicMajorChords[6, 0] = "Db";
			gf.MusicMajorChords[7, 0] = "D";
			gf.MusicMajorChords[8, 0] = "Eb";
			gf.MusicMajorChords[9, 0] = "E";
			gf.MusicMajorChords[10, 0] = "F";
			gf.MusicMajorChords[11, 0] = "Gb";
			gf.MusicMajorChords[0, 1] = "G";
			gf.MusicMajorChords[1, 1] = "G#";
			gf.MusicMajorChords[2, 1] = "A";
			gf.MusicMajorChords[3, 1] = "A#";
			gf.MusicMajorChords[4, 1] = "B";
			gf.MusicMajorChords[5, 1] = "C";
			gf.MusicMajorChords[6, 1] = "C#";
			gf.MusicMajorChords[7, 1] = "D";
			gf.MusicMajorChords[8, 1] = "D#";
			gf.MusicMajorChords[9, 1] = "E";
			gf.MusicMajorChords[10, 1] = "F";
			gf.MusicMajorChords[11, 1] = "F#";
			gf.MusicMinorChords[0, 0] = "Gm";
			gf.MusicMinorChords[1, 0] = "Abm";
			gf.MusicMinorChords[2, 0] = "Am";
			gf.MusicMinorChords[3, 0] = "Bbm";
			gf.MusicMinorChords[4, 0] = "Bm";
			gf.MusicMinorChords[5, 0] = "Cm";
			gf.MusicMinorChords[6, 0] = "Dbm";
			gf.MusicMinorChords[7, 0] = "Dm";
			gf.MusicMinorChords[8, 0] = "Ebm";
			gf.MusicMinorChords[9, 0] = "Em";
			gf.MusicMinorChords[10, 0] = "Fm";
			gf.MusicMinorChords[11, 0] = "Gbm";
			gf.MusicMinorChords[0, 1] = "Gm";
			gf.MusicMinorChords[1, 1] = "G#m";
			gf.MusicMinorChords[2, 1] = "Am";
			gf.MusicMinorChords[3, 1] = "A#m";
			gf.MusicMinorChords[4, 1] = "Bm";
			gf.MusicMinorChords[5, 1] = "Cm";
			gf.MusicMinorChords[6, 1] = "C#m";
			gf.MusicMinorChords[7, 1] = "Dm";
			gf.MusicMinorChords[8, 1] = "D#m";
			gf.MusicMinorChords[9, 1] = "Em";
			gf.MusicMinorChords[10, 1] = "Fm";
			gf.MusicMinorChords[11, 1] = "F#m";
		}
		public static void OldGenerateMusicKeysList()
		{
			gf.MusicMajorKeys[0] = "G";
			gf.MusicMajorKeys[1] = "Ab";
			gf.MusicMajorKeys[2] = "A";
			gf.MusicMajorKeys[3] = "Bb";
			gf.MusicMajorKeys[4] = "B";
			gf.MusicMajorKeys[5] = "C";
			gf.MusicMajorKeys[6] = "Db";
			gf.MusicMajorKeys[7] = "D";
			gf.MusicMajorKeys[8] = "Eb";
			gf.MusicMajorKeys[9] = "E";
			gf.MusicMajorKeys[10] = "F";
			gf.MusicMajorKeys[11] = "Gb";
			gf.MusicMinorKeys[0] = "Gm";
			gf.MusicMinorKeys[1] = "Abm";
			gf.MusicMinorKeys[2] = "Am";
			gf.MusicMinorKeys[3] = "Bbm";
			gf.MusicMinorKeys[4] = "Bm";
			gf.MusicMinorKeys[5] = "Cm";
			gf.MusicMinorKeys[6] = "Dbm";
			gf.MusicMinorKeys[7] = "Dm";
			gf.MusicMinorKeys[8] = "Ebm";
			gf.MusicMinorKeys[9] = "Em";
			gf.MusicMinorKeys[10] = "Fm";
			gf.MusicMinorKeys[11] = "Gbm";
			gf.MusicMajorChords[0, 0] = "G";
			gf.MusicMajorChords[1, 0] = "Ab";
			gf.MusicMajorChords[2, 0] = "A";
			gf.MusicMajorChords[3, 0] = "Bb";
			gf.MusicMajorChords[4, 0] = "B";
			gf.MusicMajorChords[5, 0] = "C";
			gf.MusicMajorChords[6, 0] = "Db";
			gf.MusicMajorChords[7, 0] = "D";
			gf.MusicMajorChords[8, 0] = "Eb";
			gf.MusicMajorChords[9, 0] = "E";
			gf.MusicMajorChords[10, 0] = "F";
			gf.MusicMajorChords[11, 0] = "Gb";
			gf.MusicMajorChords[0, 1] = "G";
			gf.MusicMajorChords[1, 1] = "G#";
			gf.MusicMajorChords[2, 1] = "A";
			gf.MusicMajorChords[3, 1] = "A#";
			gf.MusicMajorChords[4, 1] = "B";
			gf.MusicMajorChords[5, 1] = "C";
			gf.MusicMajorChords[6, 1] = "C#";
			gf.MusicMajorChords[7, 1] = "D";
			gf.MusicMajorChords[8, 1] = "D#";
			gf.MusicMajorChords[9, 1] = "E";
			gf.MusicMajorChords[10, 1] = "F";
			gf.MusicMajorChords[11, 1] = "F#";
			gf.MusicMinorChords[0, 0] = "Gm";
			gf.MusicMinorChords[1, 0] = "Abm";
			gf.MusicMinorChords[2, 0] = "Am";
			gf.MusicMinorChords[3, 0] = "Bbm";
			gf.MusicMinorChords[4, 0] = "Bm";
			gf.MusicMinorChords[5, 0] = "Cm";
			gf.MusicMinorChords[6, 0] = "Dbm";
			gf.MusicMinorChords[7, 0] = "Dm";
			gf.MusicMinorChords[8, 0] = "Ebm";
			gf.MusicMinorChords[9, 0] = "Em";
			gf.MusicMinorChords[10, 0] = "Fm";
			gf.MusicMinorChords[11, 0] = "Gbm";
			gf.MusicMinorChords[0, 1] = "Gm";
			gf.MusicMinorChords[1, 1] = "G#m";
			gf.MusicMinorChords[2, 1] = "Am";
			gf.MusicMinorChords[3, 1] = "A#m";
			gf.MusicMinorChords[4, 1] = "Bm";
			gf.MusicMinorChords[5, 1] = "Cm";
			gf.MusicMinorChords[6, 1] = "C#m";
			gf.MusicMinorChords[7, 1] = "Dm";
			gf.MusicMinorChords[8, 1] = "D#m";
			gf.MusicMinorChords[9, 1] = "Em";
			gf.MusicMinorChords[10, 1] = "Fm";
			gf.MusicMinorChords[11, 1] = "F#m";
		}
		public static int GetDataInt(Recordset rs, string Fieldname)
		{
			int result;
			try
			{
				result = gf.ObjToInt(rs.Fields[Fieldname].Value, false);
			}
			catch
			{
				result = 0;
			}
			return result;
		}
		public static int GetDataInt(Recordset rs, string Fieldname, bool Minus1IfBlank)
		{
			int result;
			try
			{
				result = gf.ObjToInt(rs.Fields[Fieldname].Value, Minus1IfBlank);
			}
			catch
			{
				result = (Minus1IfBlank ? -1 : 0);
			}
			return result;
		}
		public static double GetDataDouble(Recordset rs, string Fieldname)
		{
			double result;
			try
			{
				result = gf.ObjToDouble(rs.Fields[Fieldname].Value);
			}
			catch
			{
				result = 0.0;
			}
			return result;
		}
		public static string GetDataString(Recordset rs, string Fieldname)
		{
			string result;
			try
			{
				result = gf.ObjToString(rs.Fields[Fieldname].Value);
			}
			catch
			{
				result = "";
			}
			return result;
		}
		public static int ObjToInt(object InValue)
		{
			bool minus1IfBlank = false;
			return gf.ObjToInt(InValue, minus1IfBlank);
		}
		public static int ObjToInt(object InValue, bool Minus1IfBlank)
		{
			int result;
			try
			{
				result = Convert.ToInt32(InValue);
			}
			catch
			{
				result = (Minus1IfBlank ? -1 : 0);
			}
			return result;
		}
		public static double ObjToDouble(object InValue)
		{
			double result;
			try
			{
				result = Convert.ToDouble(InValue);
			}
			catch
			{
				result = 0.0;
			}
			return result;
		}
		public static string ObjToString(object InValue)
		{
			string result;
			try
			{
				result = Convert.ToString(InValue);
			}
			catch
			{
				result = "";
			}
			return result;
		}
		public static int StringToInt(char InChar)
		{
			int result;
			try
			{
				result = (int)InChar;
			}
			catch
			{
				result = 0;
			}
			return result;
		}
		public static int StringToInt(string InString)
		{
			return gf.StringToInt(InString, false);
		}
		public static int StringToInt(string InString, bool Minus1IfBlank)
		{
			int result;
			try
			{
				InString = InString.Replace("*", "");
				InString = InString.Replace(" ", "");
				result = (int)Convert.ToDouble(InString);
			}
			catch
			{
				result = (Minus1IfBlank ? -1 : 0);
			}
			return result;
		}
		public static DateTime ObjToDate(object InValue)
		{
			DateTime result;
			try
			{
				DateTime dateTime = (DateTime)InValue;
				result = dateTime;
			}
			catch
			{
				result = DateTime.Now;
			}
			return result;
		}
		public static void SingleArraySort(string[] InArray)
		{
			gf.SingleArraySort(InArray, true);
		}
		public static void SingleArraySort(string[] InArray, bool SortAscending)
		{
			Array.Sort<string>(InArray);
			if (!SortAscending)
			{
				Array.Reverse(InArray);
			}
		}
		public static int GetFolderNumber(string InName)
		{
			return gf.GetFolderNumber(InName, false);
		}
		public static int GetFolderNumber(string InName, bool ZeroIfInvalid)
		{
			int result;
			for (int i = 0; i < 41; i++)
			{
				if (InName == gf.FolderName[i])
				{
					result = i;
					return result;
				}
			}
			if (ZeroIfInvalid)
			{
				result = 0;
				return result;
			}
			result = 1;
			return result;
		}
		public static bool MusicFound(string MusicTitle1)
		{
			return gf.MusicFound(MusicTitle1, "");
		}
		public static bool MusicFound(string MusicTitle1, string MusicTitle2)
		{
			return gf.MusicFound(MusicTitle1, MusicTitle2, false);
		}
		public static bool MusicFound(string MusicTitle1, string MusicTitle2, bool StoreDirPath)
		{
			if (gf.TotalMusicFiles < 0)
			{
				gf.TotalMusicFiles = 0;
				gf.MusicBuildContinue = true;
				gf.MusicBuildStartTime = DateTime.Now;
				gf.MusicBuildLapseTime = new TimeSpan(0L);
				gf.BuildMusicFilesListArray(gf.MediaDir, StoreDirPath);
			}
			bool result;
			if (gf.TotalMusicFiles < 1)
			{
				result = false;
			}
			else
			{
				for (int i = 0; i < gf.TotalMusicFiles; i++)
				{
					if (gf.MediaFilesList[i, 0].ToLower() == MusicTitle1.ToLower())
					{
						result = true;
						return result;
					}
					if (MusicTitle2 != "")
					{
						if (gf.MediaFilesList[i, 0].ToLower() == MusicTitle2.ToLower())
						{
							result = true;
							return result;
						}
					}
				}
				result = false;
			}
			return result;
		}
		public static void BuildMusicFilesListArray(string FolderPath, bool StoreDirPath)
		{
			if (!(FolderPath == "") && gf.MusicBuildContinue && !(!Directory.Exists(FolderPath) | gf.Mid(FolderPath, 1) == ":\\System Volume Information\\"))
			{
				gf.MusicBuildLapseTime = DateTime.Now.Subtract(gf.MusicBuildStartTime);
				if (gf.MusicBuildLapseTime.Seconds > 10)
				{
					gf.MusicBuildContinue = false;
				}
				else
				{
					string[] array;
					for (int i = 0; i < gf.TotalMediaFileExt; i++)
					{
						try
						{
							string[] files = Directory.GetFiles(FolderPath, "*" + gf.MediaFileExtension[i, 0]);
							array = files;
							for (int j = 0; j < array.Length; j++)
							{
								string text = array[j];
								string text2 = text;
								gf.MediaFilesList[gf.TotalMusicFiles, 0] = gf.GetDisplayNameOnly(ref text2, false);
								gf.MediaFilesList[gf.TotalMusicFiles, 1] = gf.MediaFileExtension[i, 0];
								int iLen = text2.Length - (gf.MediaFilesList[gf.TotalMusicFiles, 0].Length + gf.MediaFilesList[gf.TotalMusicFiles, 1].Length);
								gf.MediaFilesList[gf.TotalMusicFiles, 2] = gf.Left(text2, iLen);
								gf.TotalMusicFiles++;
							}
						}
						catch
						{
						}
					}
					string[] directories = Directory.GetDirectories(FolderPath);
					if (directories.Length > 0)
					{
						gf.SingleArraySort(directories, true);
					}
					array = directories;
					for (int j = 0; j < array.Length; j++)
					{
						string str = array[j];
						gf.BuildMusicFilesListArray(str + "\\", StoreDirPath);
					}
				}
			}
		}
		public static string GetMediaFileName(string MusicTitle1, string MusicTitle2)
		{
			string text = "";
			string text2 = "";
			return gf.GetMediaFileName(MusicTitle1, MusicTitle2, ref text, ref text2, false);
		}
		public static string GetMediaFileName(string MusicTitle1, string MusicTitle2, ref string DirPath)
		{
			string text = "";
			return gf.GetMediaFileName(MusicTitle1, MusicTitle2, ref DirPath, ref text, false);
		}
		public static string GetMediaFileName(string MusicTitle1, string MusicTitle2, ref string DirPath, ref string FileName)
		{
			return gf.GetMediaFileName(MusicTitle1, MusicTitle2, ref DirPath, ref FileName, false);
		}
		public static string GetMediaFileName(string MusicTitle1, string MusicTitle2, ref string DirPath, ref string FileName, bool StoreDirPath)
		{
			string result;
			if (StoreDirPath & gf.TotalMusicFiles < 1)
			{
				result = "";
			}
			else
			{
				for (int i = 0; i <= 1; i++)
				{
					string text = (i == 0) ? MusicTitle1 : MusicTitle2;
					for (int j = 0; j < gf.TotalMediaFileExt; j++)
					{
						if (StoreDirPath)
						{
							for (int k = 0; k < gf.TotalMusicFiles; k++)
							{
								if (gf.MediaFilesList[k, 0] == text)
								{
									if (gf.MediaFilesList[k, 1] == gf.MediaFileExtension[j, 0])
									{
										DirPath = gf.MediaFilesList[k, 2];
										FileName = gf.MediaFilesList[k, 0] + gf.MediaFilesList[k, 1];
										result = DirPath + FileName;
										return result;
									}
								}
							}
						}
						else
						{
							string mediaFileNameFromDir = gf.GetMediaFileNameFromDir(gf.MediaDir, gf.MediaFileExtension[j, 0], text, ref DirPath, ref FileName);
							if (mediaFileNameFromDir != "")
							{
								result = mediaFileNameFromDir;
								return result;
							}
						}
					}
				}
				result = "";
			}
			return result;
		}
		public static string GetMediaFileNameFromDir(string FolderPath, string MusicExtension, string MusicTitle1)
		{
			string text = "";
			string text2 = "";
			return gf.GetMediaFileNameFromDir(FolderPath, MusicExtension, MusicTitle1, ref text, ref text2);
		}
		public static string GetMediaFileNameFromDir(string FolderPath, string MusicExtension, string MusicTitle1, ref string DirPath)
		{
			string text = "";
			return gf.GetMediaFileNameFromDir(FolderPath, MusicExtension, MusicTitle1, ref DirPath, ref text);
		}
		public static string GetMediaFileNameFromDir(string FolderPath, string MusicExtension, string MusicTitle1, ref string DirPath, ref string FileName)
		{
			string result;
			if (FolderPath == "" | !Directory.Exists(FolderPath) | gf.Mid(FolderPath, 1) == ":\\System Volume Information\\")
			{
				result = "";
			}
			else
			{
				if (File.Exists(FolderPath + MusicTitle1 + MusicExtension))
				{
					DirPath = FolderPath;
					FileName = MusicTitle1 + MusicExtension;
					result = DirPath + FileName;
				}
				else
				{
					string[] directories = Directory.GetDirectories(FolderPath);
					if (directories.Length > 0)
					{
						gf.SingleArraySort(directories, true);
					}
					string[] array = directories;
					for (int i = 0; i < array.Length; i++)
					{
						string str = array[i];
						string mediaFileNameFromDir = gf.GetMediaFileNameFromDir(str + "\\", MusicExtension, MusicTitle1, ref DirPath, ref FileName);
						if (mediaFileNameFromDir != "")
						{
							result = mediaFileNameFromDir;
							return result;
						}
					}
					result = "";
				}
			}
			return result;
		}
		public static int FormatImageContainers(ref ImageCanvas[] InCanvas, int MaxCanvas, int InImagesCount, int w, int h, int LeftOffset, int TopOffset)
		{
			int result = 0;
			for (int i = 0; i < MaxCanvas; i++)
			{
				InCanvas[i].PosWidth = w;
				InCanvas[i].PosHeight = h;
				InCanvas[i].PosLeft = (w + 5) * (i % gf.ThumbImagesPerRow) + LeftOffset;
				InCanvas[i].PosTop = TopOffset + (h + 5) * (i / gf.ThumbImagesPerRow);
				if (i < InImagesCount)
				{
					InCanvas[i].Visible = true;
					result = i + 1;
				}
				else
				{
					InCanvas[i].Visible = false;
				}
			}
			return result;
		}
		public static void ShowThumbImage(ref ImageCanvas InCanvas, int InCanvasIndex, int InWidth, int InHeight, ref string[] FileArray, string[] ImageArray, int FirstRef, int MaxDisplay, ToolTip InToolTip, string InPrefix, int CurSelectedSlide, bool ExternalPP)
		{
			if (InCanvasIndex >= MaxDisplay)
			{
				InToolTip.SetToolTip(InCanvas, "");
				FileArray[InCanvasIndex] = "";
				InCanvas.FileName = "";
				InCanvas.Visible = false;
			}
			else
			{
				int num = FirstRef + InCanvasIndex + 1;
				int posWidth = InCanvas.PosWidth;
				int posHeight = InCanvas.PosHeight;
				string text = ImageArray[FirstRef + InCanvasIndex];
				string caption;
				if (InCanvas.PowerPoint)
				{
					caption = num.ToString();
					InCanvas.SlideNumber = num;
				}
				else
				{
					caption = gf.GetDisplayNameOnly(ref ImageArray[FirstRef + InCanvasIndex], false, true);
					InCanvas.SlideNumber = 0;
					if (gf.Right(text, 4) == ".ppt")
					{
						text = gf.ExtPPrefix + Path.GetFileNameWithoutExtension(text) + ".jpg";
					}
					if (InCanvas.FileName == text && !ExternalPP)
					{
						int num2 = 0;
						int num3 = 0;
						gf.CalcImageToFit(InCanvas.ImageRatio, InCanvas.PosWidth, InCanvas.PosHeight, ref num2, ref num3);
						InCanvas.Width = num2;
						InCanvas.Height = num3;
						InCanvas.Left = InCanvas.PosLeft + (int)((float)(InCanvas.PosWidth - num2) / 2f);
						InCanvas.Top = InCanvas.PosTop + (int)((float)(InCanvas.PosHeight - num3) / 2f);
						return;
					}
				}
				int num4 = 0;
				int num5 = 0;
				int num6 = 0;
				int num7 = 0;
				try
				{
					Image image = Image.FromFile(text);
					InCanvas.SetImageRatio(image.Width, image.Height);
					gf.CalcImageToFit(InCanvas.ImageRatio, posWidth, posHeight, ref num4, ref num5, true, ref num6, ref num7);
					if (!(num4 <= 0 | num5 <= 0))
					{
						Image image2 = new Bitmap(num6, num7, PixelFormat.Format24bppRgb);
						Graphics graphics = Graphics.FromImage(image2);
						Rectangle rect = new Rectangle(0, 0, num6, num7);
						if (InCanvas.PowerPoint)
						{
							Font font = new Font("Microsoft Sans Serif", (float)num6 / 12f);
							int num8 = (int)((num6 >= num7) ? ((float)num6 * 0.04f) : ((float)num7 * 0.04f));
							Rectangle rect2 = new Rectangle(num8, num8, num6 - num8 * 2, num7 - num8 * 2);
							graphics.DrawImage(image, rect2);
							string text2 = num.ToString();
							PointF pointF = new PointF((float)(num8 + 2), (float)(num8 + 2));
							SizeF sizeF = graphics.MeasureString(text2, font);
							graphics.FillRectangle(new SolidBrush(gf.BlackScreenColour), pointF.X + 3f, pointF.Y + 3f, sizeF.Width, sizeF.Height);
							graphics.FillRectangle(new SolidBrush(Color.Yellow), pointF.X, pointF.Y, sizeF.Width, sizeF.Height);
							graphics.DrawString(text2, font, new SolidBrush(gf.BlackScreenColour), pointF.X, pointF.Y);
							if (CurSelectedSlide == num)
							{
								graphics.DrawRectangle(new Pen(new SolidBrush(Color.Red), (float)((int)font.Size)), rect);
							}
							else
							{
								graphics.DrawRectangle(new Pen(new SolidBrush(InCanvas.Parent.BackColor), (float)((int)font.Size)), rect);
							}
						}
						else
						{
							if (ExternalPP)
							{
								Font font = new Font("Microsoft Sans Serif", (float)num6 / 12f);
								int num8 = (int)((num6 >= num7) ? ((float)num6 * 0.04f) : ((float)num7 * 0.04f));
								Rectangle rect2 = new Rectangle(num8, num8, num6 - num8 * 2, num7 - num8 * 2);
								graphics.DrawImage(image, rect2);
								if (CurSelectedSlide == num)
								{
									graphics.DrawRectangle(new Pen(new SolidBrush(Color.Red), (float)((int)font.Size)), rect);
								}
								else
								{
									graphics.DrawRectangle(new Pen(new SolidBrush(InCanvas.Parent.BackColor), (float)((int)font.Size)), rect);
								}
							}
							else
							{
								graphics.DrawImage(image, rect);
							}
						}
						int num9 = (posWidth - num4) / 2;
						int num10 = (posHeight - num5) / 2;
						InCanvas.Left = InCanvas.PosLeft + num9;
						InCanvas.Top = InCanvas.PosTop + num10;
						InCanvas.Width = num4;
						InCanvas.Height = num5;
						InToolTip.SetToolTip(InCanvas, caption);
						FileArray[InCanvasIndex] = ImageArray[FirstRef + InCanvasIndex];
						InCanvas.FileName = text;
						InCanvas.image = image2;
						InCanvas.Visible = true;
						InCanvas.Invalidate();
					}
				}
				catch
				{
				}
			}
		}
		public static float SetImageRatio(int InImageWidth, int InImageHeight)
		{
			float result;
			try
			{
				result = (float)InImageWidth / (float)InImageHeight;
			}
			catch
			{
				result = 1f;
			}
			return result;
		}
		public static void CalcImageToFit(float InImageRatio, int InContainerWidth, int InContainerHeight, ref int NewImageWidth, ref int NewImageHeight)
		{
			int num = 0;
			int num2 = 0;
			gf.CalcImageToFit(InImageRatio, InContainerWidth, InContainerHeight, ref NewImageWidth, ref NewImageHeight, false, ref num, ref num2);
		}
		public static void CalcImageToFit(float InImageRatio, int InContainerWidth, int InContainerHeight, ref int NewImageWidth, ref int NewImageHeight, bool ComputeStoredImage, ref int StoredImageWidth, ref int StoredImageHeight)
		{
			float num = (float)InContainerWidth / (float)InContainerHeight;
			if (num < InImageRatio)
			{
				NewImageWidth = InContainerWidth;
				NewImageHeight = (int)((float)NewImageWidth / InImageRatio);
				if (ComputeStoredImage)
				{
					StoredImageWidth = 200;
					StoredImageHeight = (int)((float)StoredImageWidth / InImageRatio);
				}
			}
			else
			{
				NewImageHeight = InContainerHeight;
				NewImageWidth = (int)((float)NewImageHeight * InImageRatio);
				if (ComputeStoredImage)
				{
					StoredImageHeight = 150;
					StoredImageWidth = (int)((float)StoredImageHeight * InImageRatio);
				}
			}
		}
		public static void LoadBibleVersions(ref TabControl InTab)
		{
			try
			{
				InTab.TabPages.Clear();
				InTab.ShowToolTips = true;
				gf.HB_TotalVersions = 0;
				string fullSearchString = "select * from Biblefolder where NAME like \"*\" and displayorder >=0 order by displayorder, NAME";
				Recordset recordSet = gf.GetRecordSet(gf.ConnectStringBibleDB, fullSearchString);
				if (recordSet != null && !recordSet.EOF)
				{
					recordSet.MoveFirst();
					while (!recordSet.EOF)
					{
						if (gf.HB_TotalVersions <= 250)
						{
							TabPage tabPage = new TabPage();
							InTab.Controls.Add(tabPage);
							gf.HB_Versions[gf.HB_TotalVersions, 1] = gf.GetDataString(recordSet, "NAME");
							gf.HB_Versions[gf.HB_TotalVersions, 4] = gf.BibleDir + gf.GetDataString(recordSet, "FILENAME");
							gf.HB_Versions[gf.HB_TotalVersions, 2] = gf.GetDataString(recordSet, "DESCRIPTION");
							gf.HB_Versions[gf.HB_TotalVersions, 3] = gf.GetDataString(recordSet, "COPYRIGHT");
							gf.HB_Versions[gf.HB_TotalVersions, 5] = "1";
							gf.HB_Versions[gf.HB_TotalVersions, 5] = gf.GetDataString(recordSet, "SONGFOLDER");
							gf.HB_Versions[gf.HB_TotalVersions, 6] = "80";
							gf.HB_Versions[gf.HB_TotalVersions, 6] = gf.GetDataString(recordSet, "SIZE");
							tabPage.Text = gf.HB_Versions[gf.HB_TotalVersions, 1];
							tabPage.ToolTipText = gf.HB_Versions[gf.HB_TotalVersions, 2];
							if (gf.StringToInt(gf.HB_Versions[gf.HB_TotalVersions, 5]) < 1)
							{
								gf.HB_Versions[gf.HB_TotalVersions, 5] = "1";
							}
							if (gf.StringToInt(gf.HB_Versions[gf.HB_TotalVersions, 6]) < 5 | gf.StringToInt(gf.HB_Versions[gf.HB_TotalVersions, 6]) > 200)
							{
								gf.HB_Versions[gf.HB_TotalVersions, 6] = "80";
							}
							gf.HB_TotalVersions++;
						}
						recordSet.MoveNext();
					}
					recordSet.Close();
				}
				if (gf.HB_TotalVersions > 0)
				{
					InTab.Enabled = true;
				}
				else
				{
					TabPage tabPage = new TabPage();
					tabPage.Text = "No Bible";
					InTab.Controls.Add(tabPage);
					InTab.Enabled = false;
				}
			}
			catch
			{
			}
		}
		public static bool LoadBibleBooksList(TabControl InTab, ref ComboBox InChapterList, bool ShowSearchResultsLine, RichTextBox OutputTextBox)
		{
			gf.HB_CurVersionTabIndex = InTab.SelectedIndex;
			bool result;
			if (gf.LoadBibleBooksList(gf.HB_CurVersionTabIndex, ref InChapterList, false, ShowSearchResultsLine))
			{
				result = true;
			}
			else
			{
				if (OutputTextBox != null)
				{
					OutputTextBox.Text = "";
				}
				result = false;
			}
			return result;
		}
		public static bool LoadBibleBooksList(int InBibleVersion, ref ComboBox InChapterList, bool ShowAllBooksLine, bool ShowSearchResultsLine)
		{
			gf.HBFilename = gf.GetBibleFileName(InBibleVersion);
			int num = (InChapterList.SelectedIndex < 0) ? 0 : InChapterList.SelectedIndex;
			InChapterList.Items.Clear();
			if (ShowAllBooksLine)
			{
				InChapterList.Items.Add("All Books");
			}
			string fullSearchString = "select * from Bible where book=0 and chapter=10 and (verse >0 and verse <=" + 66.ToString() + ") order by verse";
			Recordset recordSet = gf.GetRecordSet(gf.ConnectStringDef + gf.HBFilename, fullSearchString);
			bool result;
			if (recordSet != null && !recordSet.EOF)
			{
				recordSet.MoveFirst();
				while (!recordSet.EOF)
				{
					gf.HBVersionBookName[gf.GetDataInt(recordSet, "verse")] = gf.GetDataString(recordSet, "bibletext");
					InChapterList.Items.Add(gf.GetDataString(recordSet, "bibletext"));
					recordSet.MoveNext();
				}
				if (ShowSearchResultsLine)
				{
					InChapterList.Items.Add("Search Results:");
					InChapterList.SelectedIndex = InChapterList.Items.Count - 1;
				}
				else
				{
					InChapterList.SelectedIndex = ((num < 66) ? num : 0);
				}
				result = true;
			}
			else
			{
				result = false;
			}
			return result;
		}
		public static string GetBibleFileName(int SelectedVersion)
		{
			string fullSearchString = "select * from Biblefolder where DISPLAYORDER = " + SelectedVersion.ToString();
			Recordset recordSet = gf.GetRecordSet(gf.ConnectStringBibleDB, fullSearchString);
			string result;
			if (recordSet != null && !recordSet.EOF)
			{
				recordSet.MoveFirst();
				if (gf.HB_TotalVersions <= 250)
				{
					result = gf.BibleDir + gf.GetDataString(recordSet, "filename");
					return result;
				}
			}
			result = "";
			return result;
		}
		public static bool LoadBiblePassagesFromTabIndex(int InBiBleVersion, ComboBox InBookList, ref RichTextBox InTextBox, bool InShowVerses)
		{
			InTextBox.Clear();
			StringBuilder stringBuilder = new StringBuilder();
			bool result = gf.LoadBiblePassages(InBiBleVersion, InBookList.SelectedIndex + 1, ref stringBuilder, InShowVerses, true, true, 1, 1, 0, 0, false, false, true, false);
			InTextBox.Text = stringBuilder.ToString();
			return result;
		}
		public static bool LoadBiblePassages(int InBiBleVersion, int InBookNumber, ref StringBuilder InTextString, bool InShowVerses, bool DoCompleteBook, bool TrackOutput, int ChapterStart, int VerseStart, int ChapterEnd, int VerseEnd, bool AdHocListing, bool NoneSpacingText, bool ShowRepeatingChapters, bool ShowFormatTags)
		{
			bool result;
			try
			{
				string connectString = gf.ConnectStringDef + gf.HB_Versions[InBiBleVersion, 4];
				string text = "";
				Database daoDb = gf.GetDaoDb(connectString);
				string fullSearchString;
				Recordset recordSet;
				if (AdHocListing)
				{
					fullSearchString = "select * from Bible where book=0 and chapter=10 and verse=" + InBookNumber.ToString();
					recordSet = gf.GetRecordSet(daoDb, fullSearchString);
					if (recordSet != null && !recordSet.EOF)
					{
						recordSet.MoveFirst();
						text = gf.GetDataString(recordSet, "bibletext");
					}
				}
				if (DoCompleteBook)
				{
					fullSearchString = "select * from Bible where book=" + InBookNumber.ToString() + " order by chapter, verse";
				}
				else
				{
					string text2 = "";
					string text3 = "";
					if (ChapterEnd > 0)
					{
						text2 = " and chapter <=" + ChapterEnd.ToString() + " ";
					}
					if (VerseEnd > 0)
					{
						text3 = " and verse <=" + VerseEnd.ToString() + " ";
					}
					fullSearchString = string.Concat(new string[]
					{
						"select * from Bible where book=",
						InBookNumber.ToString(),
						" and chapter >=",
						ChapterStart.ToString(),
						" ",
						text2,
						" and verse >=",
						VerseStart.ToString(),
						" ",
						text3,
						" order by book, chapter, verse"
					});
				}
				StringBuilder stringBuilder = new StringBuilder();
				char c = '\u3000';
				int num = 0;
				int num2 = 0;
				string str = (ShowFormatTags && !AdHocListing) ? '\u0098'.ToString() : " ";
				recordSet = gf.GetRecordSet(daoDb, fullSearchString);
				if (recordSet != null && !recordSet.EOF)
				{
					recordSet.MoveFirst();
					while (!recordSet.EOF)
					{
						num2++;
						int dataInt = gf.GetDataInt(recordSet, "chapter");
						int dataInt2 = gf.GetDataInt(recordSet, "verse");
						string text4 = ((ShowRepeatingChapters || dataInt != num) ? (dataInt.ToString() + ":") : "") + dataInt2.ToString() + str;
						num = dataInt;
						string text5 = InShowVerses ? (gf.GetDataString(recordSet, "bibletext") ?? "") : "";
						if (TrackOutput)
						{
							gf.HB_VersesLocation[num2, 0] = InBiBleVersion;
							gf.HB_VersesLocation[num2, 1] = InBookNumber;
							gf.HB_VersesLocation[num2, 2] = dataInt;
							gf.HB_VersesLocation[num2, 3] = dataInt2;
							gf.HB_VersesLocation[num2, 4] = stringBuilder.Length;
							stringBuilder.Append(string.Concat(new string[]
							{
								text,
								text4,
								" ",
								text5,
								"\n\n"
							}));
							gf.HB_VersesLocation[num2, 5] = stringBuilder.Length + 1 - gf.HB_VersesLocation[num2, 4];
						}
						else
						{
							if (AdHocListing)
							{
								stringBuilder.Append(string.Concat(new string[]
								{
									text5,
									" (",
									text,
									text4,
									")\n"
								}));
							}
							else
							{
								stringBuilder.Append(text4 + (NoneSpacingText ? c.ToString() : " ") + text5 + "\n");
							}
						}
						recordSet.MoveNext();
					}
				}
				if (TrackOutput)
				{
					gf.HB_VersesLocation[0, 0] = num2;
				}
				InTextString.Append(gf.TrimEnd(stringBuilder.ToString()));
				if (recordSet != null)
				{
				}
				result = true;
			}
			catch
			{
				result = false;
			}
			return result;
		}
		public static bool RefreshBiblePassages(int InBibleVersion, ComboBox InBookList, ref RichTextBox InTextContainer)
		{
			return gf.RefreshBiblePassages(InBibleVersion, InBookList, ref InTextContainer, true);
		}
		public static bool RefreshBiblePassages(int InBibleVersion, ComboBox InBookList, ref RichTextBox InTextContainer, bool InShowVerses)
		{
			gf.HBConvertVersion(InBibleVersion);
			StringBuilder stringBuilder = new StringBuilder();
			bool result;
			try
			{
				string connectString = gf.ConnectStringDef + gf.HB_Versions[InBibleVersion, 4];
				Database daoDb = gf.GetDaoDb(connectString);
				Recordset recordset = null;
				for (int i = 1; i <= gf.HB_VersesLocation[0, 0]; i++)
				{
					try
					{
						string fullSearchString = string.Concat(new string[]
						{
							"select * from bible where book =",
							gf.HB_VersesLocation[i, 1].ToString(),
							" and chapter=",
							gf.HB_VersesLocation[i, 2].ToString(),
							" and verse=",
							gf.HB_VersesLocation[i, 3].ToString(),
							" order by book, chapter, verse"
						});
						recordset = gf.GetRecordSet(daoDb, fullSearchString);
						if (recordset != null && !recordset.EOF)
						{
							gf.HB_VersesLocation[i, 4] = stringBuilder.Length;
							stringBuilder.Append(string.Concat(new object[]
							{
								InBookList.Items[gf.HB_VersesLocation[i, 1] - 1],
								" ",
								gf.HB_VersesLocation[i, 2],
								":",
								gf.HB_VersesLocation[i, 3],
								" ",
								InShowVerses ? gf.GetDataString(recordset, "bibletext") : "",
								"\n\n"
							}));
							gf.HB_VersesLocation[i, 5] = stringBuilder.Length + 1 - gf.HB_VersesLocation[i, 4];
							recordset.Close();
						}
					}
					catch
					{
						gf.HB_VersesLocation[i, 4] = stringBuilder.Length;
						gf.HB_VersesLocation[i, 5] = 0;
					}
				}
				InTextContainer.Text = gf.TrimEnd(stringBuilder.ToString());
				if (recordset != null)
				{
					recordset = null;
				}
				result = true;
			}
			catch
			{
				InTextContainer.Text = gf.TrimEnd(stringBuilder.ToString());
				result = false;
			}
			return result;
		}
		public static string ExtractOneInfo(ref string InString, char ExtractSym)
		{
			return gf.ExtractOneInfo(ref InString, ExtractSym, true);
		}
		public static string ExtractOneInfo(ref string InString, char ExtractSym, bool RemoveExtract)
		{
			return gf.ExtractOneInfo(ref InString, ExtractSym, RemoveExtract, true);
		}
		public static string ExtractOneInfo(ref string InString, char ExtractSym, bool RemoveExtract, bool MinusOneIfBlank)
		{
			string result;
			if (InString == null || InString.Length == 0)
			{
				if (MinusOneIfBlank)
				{
					result = "-1";
				}
				else
				{
					result = "";
				}
			}
			else
			{
				int num = InString.IndexOf(ExtractSym);
				if (num >= 0)
				{
					string text = gf.Mid(InString, 0, num);
					if (RemoveExtract)
					{
						InString = gf.Mid(InString, num + 1);
					}
					result = text;
				}
				else
				{
					string text = InString;
					if (RemoveExtract)
					{
						InString = "";
					}
					if (text == "" && MinusOneIfBlank)
					{
						result = "-1";
					}
					else
					{
						result = text;
					}
				}
			}
			return result;
		}
		public static bool HBConvertVersion(int InBibleVersion)
		{
			bool result;
			if (InBibleVersion < gf.HB_TotalVersions - 1)
			{
				result = false;
			}
			else
			{
				for (int i = 1; i <= gf.HB_VersesLocation[0, 0]; i++)
				{
					gf.HB_VersesLocation[i, 0] = InBibleVersion;
				}
				result = true;
			}
			return result;
		}
		public static bool LookUpBibleName(string FileName, ref string Name, ref string Description, ref string Copyright, ref string Info)
		{
			Name = "";
			Description = "";
			Copyright = "";
			Info = "";
			string connectString = gf.ConnectStringDef + FileName;
			try
			{
				Recordset recordSet = gf.GetRecordSet(connectString, "select * from Bible where book=0 and chapter=0 and verse=0");
				Description = gf.GetDataString(recordSet, "bibletext");
				recordSet = gf.GetRecordSet(connectString, "select * from Bible where book=0 and chapter=0 and verse=1");
				Name = gf.GetDataString(recordSet, "bibletext");
				recordSet = gf.GetRecordSet(connectString, "select * from Bible where book=0 and chapter=0 and verse=3");
				Copyright = gf.GetDataString(recordSet, "bibletext");
				recordSet = gf.GetRecordSet(connectString, "select * from Bible where book=0 and chapter=0 and verse=4");
				Info = gf.GetDataString(recordSet, "bibletext");
			}
			catch
			{
			}
			return !(Name == "") && !(Description == "");
		}
		public static string LookUpBookName(int InBibleVersion, int InBookNumber)
		{
			string result;
			try
			{
				string connectString = gf.ConnectStringDef + gf.HB_Versions[InBibleVersion, 4];
				string fullSearchString = "select * from Bible where book=0 and chapter=10 and verse=" + InBookNumber.ToString();
				Recordset recordSet = gf.GetRecordSet(connectString, fullSearchString);
				if (recordSet != null && !recordSet.EOF)
				{
					result = gf.GetDataString(recordSet, "bibletext");
					return result;
				}
			}
			catch
			{
				result = "";
				return result;
			}
			result = "";
			return result;
		}
		public void FormatText(ref gf.SongSettings InItem, Color PanelBackColour, int PanelBackColorAsScreen, Color PanelTextColor, int PaneltextColourAsRegion1)
		{
			gf.FormatText(ref InItem, PanelBackColour, PanelBackColorAsScreen, PanelTextColor, PaneltextColourAsRegion1, true);
		}
		public static void FormatText(ref gf.SongSettings InItem, Color PanelBackColour, int PanelBackColorAsScreen, Color PanelTextColor, int PaneltextColourAsRegion1, bool UseDefault)
		{
			Color[] array = new Color[2];
			int[] array2 = new int[2];
			int[] array3 = new int[4];
			int[] array4 = new int[4];
			int[] array5 = new int[4];
			int[] array6 = new int[2];
			string[] array7 = new string[2];
			int[] array8 = new int[2];
			int[] array9 = new int[2];
			int buffer_LS_Width = gf.Buffer_LS_Width;
			int buffer_LS_Height = gf.Buffer_LS_Height;
			double num = (double)gf.PreviewSampleFactor;
			int num2 = 0;
			int num3 = 0;
			int num4 = 0;
			int num5 = 0;
			if (UseDefault)
			{
				array[0] = gf.ShowFontColour[0];
				array[1] = gf.ShowFontColour[1];
				array2[0] = gf.ShowFontAlign[0, 0];
				array2[1] = gf.ShowFontAlign[0, 1];
				array3[0] = gf.ShowFontBold[InItem.FolderNo, 0];
				array3[1] = gf.ShowFontBold[InItem.FolderNo, 1];
				array4[0] = gf.ShowFontItalic[InItem.FolderNo, 0];
				array4[1] = gf.ShowFontItalic[InItem.FolderNo, 1];
				array4[2] = gf.ShowFontItalic[InItem.FolderNo, 2];
				array4[3] = gf.ShowFontItalic[InItem.FolderNo, 3];
				array5[0] = gf.ShowFontUnderline[InItem.FolderNo, 0];
				array5[1] = gf.ShowFontUnderline[InItem.FolderNo, 1];
				array6[0] = gf.ShowFontRTL[InItem.FolderNo, 0];
				array6[1] = gf.ShowFontRTL[InItem.FolderNo, 1];
				array7[0] = gf.ShowFontName[InItem.FolderNo, 0];
				array7[1] = gf.ShowFontName[InItem.FolderNo, 1];
				if (InItem.Type == "B")
				{
					array8[0] = InItem.Format.ShowFontSize[0];
					array8[1] = InItem.Format.ShowFontSize[1];
				}
				else
				{
					array8[0] = gf.ShowFontSize[InItem.FolderNo, 0];
					array8[1] = gf.ShowFontSize[InItem.FolderNo, 1];
				}
				array9[0] = gf.ShowFontVPosition[InItem.FolderNo, 0];
				array9[1] = gf.ShowFontVPosition[InItem.FolderNo, 1];
				num2 = gf.ShowLeftMargin[InItem.FolderNo];
				num3 = gf.ShowRightMargin[InItem.FolderNo];
				num4 = gf.ShowBottomMargin[InItem.FolderNo];
				if (gf.ShowSongHeadingsAlign == 1)
				{
					num5 = array2[1];
				}
				else
				{
					if (gf.ShowSongHeadingsAlign == 2)
					{
						num5 = 1;
					}
					else
					{
						if (gf.ShowSongHeadingsAlign == 3)
						{
							num5 = 2;
						}
						else
						{
							if (gf.ShowSongHeadingsAlign == 4)
							{
								num5 = 3;
							}
							else
							{
								num5 = array2[0];
							}
						}
					}
				}
			}
			else
			{
				if (!UseDefault)
				{
					array[0] = InItem.Format.ShowFontColour[0];
					array[1] = InItem.Format.ShowFontColour[1];
					array2[0] = InItem.Format.ShowFontAlign[0];
					array2[1] = InItem.Format.ShowFontAlign[1];
					array3[0] = InItem.Format.ShowFontBold[0];
					array3[1] = InItem.Format.ShowFontBold[1];
					array4[0] = InItem.Format.ShowFontItalic[0];
					array4[1] = InItem.Format.ShowFontItalic[1];
					array4[2] = InItem.Format.ShowFontItalic[2];
					array4[3] = InItem.Format.ShowFontItalic[3];
					array5[0] = InItem.Format.ShowFontUnderline[0];
					array5[1] = InItem.Format.ShowFontUnderline[1];
					array7[0] = InItem.Format.ShowFontName[0];
					array7[1] = InItem.Format.ShowFontName[1];
					array8[0] = InItem.Format.ShowFontSize[0];
					array8[1] = InItem.Format.ShowFontSize[1];
					array9[0] = InItem.Format.ShowFontVPosition[0];
					array9[1] = InItem.Format.ShowFontVPosition[1];
					num2 = InItem.Format.ShowLeftMargin;
					num3 = InItem.Format.ShowRightMargin;
					num4 = InItem.Format.ShowBottomMargin;
					if (InItem.Format.ShowSongHeadingsAlign == 1)
					{
						num5 = array2[1];
					}
					else
					{
						if (InItem.Format.ShowSongHeadingsAlign == 2)
						{
							num5 = 1;
						}
						else
						{
							if (InItem.Format.ShowSongHeadingsAlign == 3)
							{
								num5 = 2;
							}
							else
							{
								if (InItem.Format.ShowSongHeadingsAlign == 4)
								{
									num5 = 3;
								}
								else
								{
									num5 = array2[0];
								}
							}
						}
					}
				}
			}
			int num6 = gf.FolderHeadingOption[InItem.FolderNo];
			bool flag = gf.FolderHeadingFontBold[InItem.FolderNo, 0] > 0;
			bool flag2 = gf.FolderHeadingFontItalic[InItem.FolderNo, 0] > 0;
			bool flag3 = gf.FolderHeadingFontUnderline[InItem.FolderNo, 0] > 0;
			bool flag4 = gf.FolderHeadingFontItalic[InItem.FolderNo, 1] > 0;
			int num7 = num2 * buffer_LS_Width / 100;
			int num8 = buffer_LS_Width - (num7 + num3 * buffer_LS_Width / 100);
			int num9 = buffer_LS_Height - (int)(gf.TopBorderFactor * (double)buffer_LS_Height + (gf.BottomBorderFactor + 0.029999999329447746) * (double)buffer_LS_Height + (double)(num4 * buffer_LS_Height / 100));
			gf.ShowTopBorderSize = (int)((double)buffer_LS_Height * gf.TopBorderFactor);
			Image image = new Bitmap(num8, 1, PixelFormat.Format24bppRgb);
			Graphics graphics = Graphics.FromImage(image);
			SizeF layoutArea = new SizeF((float)num8, 32000f);
			int i;
			FontStyle fontStyle;
			int num12;
			double num13;
			for (i = 0; i <= 2; i++)
			{
				int num10;
				if (i < 2)
				{
					num10 = i;
				}
				else
				{
					num10 = 0;
				}
				fontStyle = FontStyle.Regular;
				FontStyle fontStyle2 = FontStyle.Regular;
				if (i == 2 & num6 != 0)
				{
					if (num6 == 2)
					{
						if (flag)
						{
							fontStyle |= FontStyle.Bold;
							fontStyle2 |= FontStyle.Bold;
						}
						if (flag2)
						{
							fontStyle |= FontStyle.Italic;
						}
						if (flag4)
						{
							fontStyle2 |= FontStyle.Italic;
						}
						if (flag3)
						{
							fontStyle |= FontStyle.Underline;
							fontStyle2 |= FontStyle.Underline;
						}
					}
					else
					{
						if (array3[num10] > 0 | flag)
						{
							fontStyle |= FontStyle.Bold;
							fontStyle2 |= FontStyle.Bold;
						}
						if (array4[num10] > 0 | flag2)
						{
							fontStyle |= FontStyle.Italic;
						}
						if (array4[num10] > 0 | flag4)
						{
							fontStyle2 |= FontStyle.Italic;
						}
						if (array5[num10] > 0 | flag3)
						{
							fontStyle |= FontStyle.Underline;
							fontStyle2 |= FontStyle.Underline;
						}
					}
				}
				else
				{
					if (array3[num10] > 0)
					{
						fontStyle |= FontStyle.Bold;
						fontStyle2 |= FontStyle.Bold;
					}
					if (array4[num10] > 0)
					{
						fontStyle |= FontStyle.Italic;
					}
					if (array5[num10] > 0)
					{
						fontStyle |= FontStyle.Underline;
						fontStyle2 |= FontStyle.Bold;
					}
					if (array4[num10] > 0 || array4[num10 + 2] > 0)
					{
						fontStyle2 |= FontStyle.Italic;
					}
				}
				InItem.Lyrics[i].ForeColour = array[num10];
				int num11 = (i == 2) ? num5 : array2[num10];
				if (num11 == 3)
				{
					InItem.Lyrics[i].TextAlign = StringAlignment.Far;
				}
				else
				{
					if (num11 == 1)
					{
						InItem.Lyrics[i].TextAlign = StringAlignment.Near;
					}
					else
					{
						InItem.Lyrics[i].TextAlign = StringAlignment.Center;
					}
				}
				num12 = gf.DisplayFontSize(array8[num10], buffer_LS_Width, i, InItem.FolderNo);
				num13 = (double)num12 / num;
				try
				{
					InItem.Lyrics[i].FS_Font = new Font(array7[num10], (float)num12, fontStyle);
					InItem.Lyrics[i].FS_ChorusFont = new Font(array7[num10], (float)num12, fontStyle2);
				}
				catch
				{
					InItem.Lyrics[i].FS_Font = new Font("Microsoft Sans Serif", (float)num12, fontStyle);
					InItem.Lyrics[i].FS_ChorusFont = new Font("Microsoft Sans Serif", (float)num12, fontStyle2);
				}
				try
				{
					InItem.Lyrics[i].Font = new Font(array7[num10], (float)((num13 > 0.0) ? num13 : 1.0), fontStyle);
					InItem.Lyrics[i].ChorusFont = new Font(array7[num10], (float)((num13 > 0.0) ? num13 : 1.0), fontStyle2);
				}
				catch
				{
					InItem.Lyrics[i].Font = new Font("Microsoft Sans Serif", (float)((num13 > 0.0) ? num13 : 1.0), fontStyle);
					InItem.Lyrics[i].ChorusFont = new Font("Microsoft Sans Serif", (float)((num13 > 0.0) ? num13 : 1.0), fontStyle2);
				}
			}
			double num14 = (double)graphics.MeasureString("A", InItem.Lyrics[2].FS_Font, layoutArea).Height * 1.1;
			if (num14 > (double)num9 / 4.0)
			{
				num14 = (double)num9 / 4.0;
			}
			for (i = 0; i <= 2; i++)
			{
				InItem.Lyrics[i].Visible = false;
				InItem.Lyrics[i].FS_Width = num8;
				InItem.Lyrics[i].FS_Left = num7;
				InItem.Lyrics[i].FS_Top = gf.SetLyricsTopPos(array9[(i < 2) ? i : 0], buffer_LS_Height) + ((i == 0) ? ((int)num14) : 0);
				if (i == 2)
				{
					InItem.Lyrics[i].FS_Height = (int)num14;
					InItem.Lyrics[i].FS_Height_R2Bound = InItem.Lyrics[i].FS_Height;
					InItem.Lyrics[0].FS_Height_R2Bound = InItem.Lyrics[1].FS_Top - InItem.Lyrics[0].FS_Top;
					InItem.Lyrics[0].Height_R2Bound = Convert.ToInt32((double)InItem.Lyrics[0].FS_Height_R2Bound / num);
				}
				else
				{
					InItem.Lyrics[i].FS_Height = num9 - InItem.Lyrics[i].FS_Top;
					InItem.Lyrics[i].FS_Height_R2Bound = InItem.Lyrics[i].FS_Height;
				}
				InItem.Lyrics[i].Width = Convert.ToInt32((double)InItem.Lyrics[i].FS_Width / num);
				InItem.Lyrics[i].Left = Convert.ToInt32((double)InItem.Lyrics[i].FS_Left / num);
				InItem.Lyrics[i].Top = Convert.ToInt32((double)InItem.Lyrics[i].FS_Top / num);
				InItem.Lyrics[i].Height = Convert.ToInt32((double)InItem.Lyrics[i].FS_Height / num);
				InItem.Lyrics[i].Height_R2Bound = Convert.ToInt32((double)InItem.Lyrics[i].FS_Height_R2Bound / num);
			}
			i = 3;
			InItem.Lyrics[i].BackColour = PanelBackColour;
			InItem.Lyrics[i].Transparent = (PanelBackColorAsScreen > 0);
			InItem.Lyrics[i].ForeColour = ((PaneltextColourAsRegion1 > 0) ? InItem.Lyrics[0].ForeColour : gf.PanelTextColour);
			InItem.Lyrics[i].FS_Width = buffer_LS_Width - buffer_LS_Width / 50;
			InItem.Lyrics[i].FS_Left = (buffer_LS_Width - InItem.Lyrics[i].FS_Width) / 2;
			fontStyle = FontStyle.Regular;
			if (gf.ShowDataDisplayFontBold > 0)
			{
				fontStyle |= FontStyle.Bold;
			}
			if (gf.ShowDataDisplayFontItalic > 0)
			{
				fontStyle |= FontStyle.Italic;
			}
			if (gf.ShowDataDisplayFontUnderline > 0)
			{
				fontStyle |= FontStyle.Underline;
			}
			InItem.Lyrics[i].TextAlign = StringAlignment.Near;
			double num15 = gf.BottomBorderFactor * (double)buffer_LS_Height;
			InItem.Lyrics[i].FS_Height = (int)(num15 * 0.8);
			InItem.Lyrics[i].FS_Top = buffer_LS_Height - InItem.Lyrics[i].FS_Height;
			num12 = 40;
			Font font;
			try
			{
				font = new Font(gf.ShowDataDisplayFontName, (float)num12, fontStyle);
			}
			catch
			{
				font = new Font("Microsoft Sans Serif", (float)num12, fontStyle);
			}
			while (graphics.MeasureString("A", font, layoutArea).Height > (float)(InItem.Lyrics[i].FS_Height * 9 / 20) & font.Size > 1f)
			{
				num12--;
				font = new Font(font.Name, (float)num12, fontStyle);
			}
			num12 = (int)font.Size + 1;
			num13 = (double)font.Size / num;
			InItem.Lyrics[i].FS_Height_R2Bound = InItem.Lyrics[i].FS_Height;
			InItem.Lyrics[i].Width = (int)((double)InItem.Lyrics[i].FS_Width / num);
			InItem.Lyrics[i].Left = (int)((double)InItem.Lyrics[i].FS_Left / num);
			InItem.Lyrics[i].Top = (int)((double)InItem.Lyrics[i].FS_Top / num);
			InItem.Lyrics[i].Height = (int)((double)InItem.Lyrics[i].FS_Height / num);
			InItem.Lyrics[i].Height_R2Bound = (int)((double)InItem.Lyrics[i].FS_Height_R2Bound / num);
			InItem.Lyrics[i].FS_Font = new Font(font.Name, (float)num12, fontStyle);
			InItem.Lyrics[i].Font = new Font(font.Name, (float)((num13 > 0.0) ? ((int)num13) : 1), fontStyle);
		}
		public static int SetLyricsTopPos(int TopSetting, int ScreenHeight)
		{
			return ScreenHeight * TopSetting / 100;
		}
		public static int DisplayFontSize(int InFontSize, int InLyricsWidth, int InNum, int Folderno)
		{
			if (InNum == 2)
			{
				try
				{
					InFontSize = InFontSize * gf.FolderHeadingPercentSize[Folderno] / 100;
				}
				catch
				{
				}
			}
			int num = InFontSize * InLyricsWidth / 960;
			return (num < 1) ? 1 : num;
		}
		public static int Load32HeaderData(string InFileName, string InContents, ref string[] ThisHeaderData)
		{
			return gf.Load32HeaderData(InFileName, InContents, ref ThisHeaderData, '>');
		}
		public static int Load32HeaderData(string InFileName, string InContents, ref string[] ThisHeaderData, char SeparatorSym)
		{
			for (int i = 0; i < 255; i++)
			{
				ThisHeaderData[i] = "";
			}
			int num = InContents.IndexOf("[");
			int num2 = InContents.IndexOf("]", num + 1);
			int result;
			if (num == 0 & num2 > 1)
			{
				num++;
				int num3 = num2 + 1;
				string inFormatString = gf.Mid(InContents, num, num2 - num + 1);
				if (gf.Convertv32FormatString(ref inFormatString, SeparatorSym) == 320)
				{
					gf.LoadHeaderData(inFormatString, ref ThisHeaderData, '>');
					result = num2;
					return result;
				}
			}
			num2 = 0;
			InContents = "";
			result = num2;
			return result;
		}
		public static string ExtractHeaderInfo(string InString, int Index, char Separator)
		{
			int num = InString.IndexOf(Index.ToString() + "=");
			string result;
			if (num >= 0)
			{
				num += Index.ToString().Length + 1;
				int num2 = InString.IndexOf(Separator, num);
				if (num2 <= num)
				{
					result = "";
				}
				else
				{
					result = gf.Mid(InString, num, num2 - num);
				}
			}
			else
			{
				result = "";
			}
			return result;
		}
		public static int Convertv32FormatString(ref string InFormatString, char InSeparator)
		{
			string text = "";
			string text2 = "";
			string text3 = "";
			return gf.Convertv32FormatString(ref InFormatString, InSeparator, ref text, ref text2, ref text3);
		}
		public static int Convertv32FormatString(ref string InFormatString, char InSeparator, ref string InfoHeading, ref string InfoFolder, ref string InfoRotate)
		{
			InFormatString = InFormatString.Replace("[", "");
			InFormatString = InFormatString.Replace("]", "");
			int result;
			if (InFormatString == "")
			{
				result = -1;
			}
			else
			{
				string text = "";
				int num = -1;
				string[] array = InFormatString.Split(new char[]
				{
					InSeparator
				});
				for (int i = 0; i <= array.GetUpperBound(0); i++)
				{
					int num2 = gf.Remap32Index(gf.ExtractOneInfo(ref array[i], '=', true, false));
					if (num2 > 1 & num2 < 10000)
					{
						object obj = text;
						text = string.Concat(new object[]
						{
							obj,
							num2.ToString(),
							"=",
							array[i],
							'>'
						});
					}
					if (num2 == 1)
					{
						num = gf.StringToInt(array[i]);
					}
					else
					{
						if (num2 == 10001)
						{
							InfoHeading = array[i];
						}
						else
						{
							if (num2 == 10002)
							{
								InfoFolder = array[i];
							}
							else
							{
								if (num2 == 10003)
								{
									InfoRotate = array[i];
								}
							}
						}
					}
				}
				InFormatString = text;
				result = num;
			}
			return result;
		}
		public static int Remap32Index(string InString)
		{
			int result;
			try
			{
				int num = (int)InString[0];
				int num2 = -1;
				int num3 = num;
				switch (num3)
				{
				case 1:
					num2 = 1;
					break;
				case 2:
					num2 = 11;
					break;
				case 3:
					num2 = 12;
					break;
				case 4:
					num2 = 13;
					break;
				case 5:
					num2 = 14;
					break;
				case 6:
					num2 = 15;
					break;
				case 7:
				case 18:
				case 25:
				case 32:
				case 33:
				case 34:
				case 35:
				case 36:
				case 37:
				case 38:
				case 39:
				case 40:
				case 43:
				case 44:
				case 45:
				case 48:
				case 49:
				case 50:
				case 53:
				case 54:
				case 55:
				case 58:
				case 59:
				case 60:
				case 63:
				case 64:
				case 65:
				case 68:
				case 69:
				case 70:
				case 73:
				case 74:
				case 75:
				case 76:
				case 77:
				case 78:
				case 79:
				case 80:
				case 88:
				case 89:
				case 90:
				case 91:
				case 92:
				case 93:
				case 94:
					break;
				case 8:
					num2 = 22;
					break;
				case 9:
					num2 = 25;
					break;
				case 10:
					num2 = 26;
					break;
				case 11:
					num2 = 27;
					break;
				case 12:
					num2 = 28;
					break;
				case 13:
					num2 = 29;
					break;
				case 14:
					num2 = 30;
					break;
				case 15:
					num2 = 31;
					break;
				case 16:
					num2 = 41;
					break;
				case 17:
					num2 = 42;
					break;
				case 19:
					num2 = 43;
					break;
				case 20:
					num2 = 44;
					break;
				case 21:
					num2 = 45;
					break;
				case 22:
					num2 = 46;
					break;
				case 23:
					num2 = 47;
					break;
				case 24:
					num2 = 48;
					break;
				case 26:
					num2 = 61;
					break;
				case 27:
					num2 = 62;
					break;
				case 28:
					num2 = 63;
					break;
				case 29:
					num2 = 64;
					break;
				case 30:
					num2 = 65;
					break;
				case 31:
					num2 = 10003;
					break;
				case 41:
					num2 = 101;
					break;
				case 42:
					num2 = 102;
					break;
				case 46:
					num2 = 106;
					break;
				case 47:
					num2 = 107;
					break;
				case 51:
					num2 = 111;
					break;
				case 52:
					num2 = 112;
					break;
				case 56:
					num2 = 116;
					break;
				case 57:
					num2 = 117;
					break;
				case 61:
					num2 = 121;
					break;
				case 62:
					num2 = 122;
					break;
				case 66:
					num2 = 131;
					break;
				case 67:
					num2 = 132;
					break;
				case 71:
					num2 = 136;
					break;
				case 72:
					num2 = 137;
					break;
				case 81:
					num2 = 151;
					break;
				case 82:
					num2 = 153;
					break;
				case 83:
					num2 = 154;
					break;
				case 84:
					num2 = 155;
					break;
				case 85:
					num2 = 170;
					break;
				case 86:
					num2 = 171;
					break;
				case 87:
					num2 = 172;
					break;
				case 95:
					num2 = 174;
					break;
				case 96:
					num2 = 180;
					break;
				default:
					switch (num3)
					{
					case 110:
						num2 = 10001;
						break;
					case 111:
						num2 = 10002;
						break;
					}
					break;
				}
				result = num2;
			}
			catch
			{
				result = -1;
			}
			return result;
		}
		public static int LoadHeaderData(string InFormatString, ref string[] ThisHeaderData, char SeparatorSym)
		{
			for (int i = 0; i < 255; i++)
			{
				ThisHeaderData[i] = "";
			}
			int result;
			if (InFormatString == "" || InFormatString[0] == '[')
			{
				result = -1;
			}
			else
			{
				string[] array = InFormatString.Split(new char[]
				{
					'>'
				});
				for (int i = 0; i <= array.GetUpperBound(0); i++)
				{
					string text = gf.ExtractOneInfo(ref array[i], '=', true, false);
					if (text != "")
					{
						int num = gf.StringToInt(text);
						if (num > 0 & num < 255)
						{
							ThisHeaderData[num] = array[i];
						}
					}
				}
				result = 1;
			}
			return result;
		}
		public static void ApplyHeaderData()
		{
			gf.ApplyHeaderData(0);
		}
		public static void ApplyHeaderData(int InMode)
		{
			int num = gf.ExtractNumericData(gf.HeaderData[1]);
			gf.IndexFileVersion = num;
			if (InMode != 1)
			{
				num = gf.ExtractNumericData(gf.HeaderData[11]);
				gf.PanelBackColour = ((gf.HeaderData[11] == "" | !gf.ValidateColour(num)) ? gf.DefaultBackColour : Color.FromArgb(Convert.ToInt32(num)));
				num = gf.ExtractNumericData(gf.HeaderData[12]);
				gf.PanelBackColourTransparent = ((num < 0 | num > 1) ? 1 : num);
				num = gf.ExtractNumericData(gf.HeaderData[13]);
				gf.PanelTextColour = ((gf.HeaderData[13] == "" | !gf.ValidateColour(num)) ? gf.DefaultForeColour : Color.FromArgb(Convert.ToInt32(num)));
				num = gf.ExtractNumericData(gf.HeaderData[14]);
				gf.PanelTextColourAsRegion1 = ((num < 0 | num > 1) ? 1 : num);
				num = gf.ExtractNumericData(gf.HeaderData[15]);
				num = ((num < 0) ? 31 : num);
				gf.ShowDataDisplayMode = gf.GetBitValue(num, 1);
				gf.ShowDataDisplaySlides = gf.GetBitValue(num, 2);
				gf.ShowDataDisplaySongs = gf.GetBitValue(num, 3);
				gf.ShowDataDisplayTitle = gf.GetBitValue(num, 4);
				gf.ShowDataDisplayCopyright = gf.GetBitValue(num, 5);
				gf.ShowDataDisplayPrevNext = gf.GetBitValue(num, 6);
				num = gf.ExtractNumericData(gf.HeaderData[16]);
				num = ((num < 6 || num > 20) ? 8 : num);
				gf.BottomBorderFactor = (double)num / 100.0;
				gf.ShowDataDisplayFontName = gf.HeaderData[17];
				if (gf.ShowDataDisplayFontName == "")
				{
					gf.ShowDataDisplayFontName = "Microsoft Sans Serif";
				}
				num = gf.ExtractNumericData(gf.HeaderData[18]);
				num = ((num < 0) ? 0 : num);
				gf.ShowDataDisplayFontBold = gf.GetBitValue(num, 1);
				gf.ShowDataDisplayFontItalic = gf.GetBitValue(num, 2);
				gf.ShowDataDisplayFontUnderline = gf.GetBitValue(num, 3);
				gf.ShowDataDisplayFontShadow = gf.GetBitValue(num, 4);
				gf.ShowDataDisplayFontOutline = gf.GetBitValue(num, 5);
				num = gf.ExtractNumericData(gf.HeaderData[19]);
				gf.ShowDataDisplayIndicatorsFontSize = ((num < 8 || num > 20) ? 8 : num);
				num = gf.ExtractNumericData(gf.HeaderData[21]);
				gf.ShowSongHeadings = ((num < 0 | num > 3) ? 1 : num);
				num = gf.ExtractNumericData(gf.HeaderData[22]);
				num = ((num < 0) ? 2 : num);
				gf.UseShadowFont = gf.GetBitValue(num, 2);
				gf.ShowNotations = gf.GetBitValue(num, 3);
				gf.ShowCapoZero = gf.GetBitValue(num, 4);
				gf.ShowInterlace = gf.GetBitValue(num, 5);
				gf.UseOutlineFont = gf.GetBitValue(num, 6);
				num = gf.ExtractNumericData(gf.HeaderData[23]);
				gf.ShowSongHeadingsAlign = ((num < 0 | num > 4) ? 0 : num);
				num = gf.ExtractNumericData(gf.HeaderData[25]);
				gf.ShowLyrics = ((num < 0 | num > 2) ? 2 : num);
				num = gf.ExtractNumericData(gf.HeaderData[26]);
				gf.ShowScreenColour[0] = ((gf.HeaderData[26] == "" | !gf.ValidateColour(num)) ? gf.DefaultBackColour : Color.FromArgb(Convert.ToInt32(num)));
				num = gf.ExtractNumericData(gf.HeaderData[27]);
				gf.ShowScreenColour[1] = ((gf.HeaderData[27] == "" | !gf.ValidateColour(num)) ? gf.ShowScreenColour[0] : Color.FromArgb(Convert.ToInt32(num)));
				num = gf.ExtractNumericData(gf.HeaderData[28]);
				gf.ShowScreenStyle = ((num < 0 | num > gf.MaxBackgroundStyleIndex) ? 0 : num);
				num = gf.ExtractNumericData(gf.HeaderData[29]);
				gf.ShowFontColour[0] = ((gf.HeaderData[29] == "" | !gf.ValidateColour(num)) ? gf.DefaultForeColour : Color.FromArgb(Convert.ToInt32(num)));
				num = gf.ExtractNumericData(gf.HeaderData[30]);
				gf.ShowFontColour[1] = ((gf.HeaderData[30] == "" | !gf.ValidateColour(num)) ? gf.DefaultForeColour : Color.FromArgb(Convert.ToInt32(num)));
				num = gf.ExtractNumericData(gf.HeaderData[31]);
				gf.ShowFontAlign[0, 0] = ((num < 0 | num > 3) ? 2 : num);
				num = gf.ExtractNumericData(gf.HeaderData[32]);
				gf.ShowFontAlign[0, 1] = ((num < 0 | num > 3) ? 2 : num);
				num = gf.ExtractNumericData(gf.HeaderData[50]);
				gf.MediaOption = ((num < 0 | num > 3) ? 0 : num);
				gf.MediaLocation = gf.HeaderData[51];
				num = gf.ExtractNumericData(gf.HeaderData[52]);
				gf.MediaVolume = ((num < 0 | num > 100) ? 50 : num);
				num = gf.ExtractNumericData(gf.HeaderData[53]);
				gf.MediaBalance = ((num < -100 | num > 100) ? 0 : num);
				num = gf.ExtractNumericData(gf.HeaderData[54]);
				gf.MediaMute = gf.GetBitValue(num, 1);
				gf.MediaRepeat = gf.GetBitValue(num, 2);
				gf.MediaWidescreen = gf.GetBitValue(num, 3);
				num = gf.ExtractNumericData(gf.HeaderData[55]);
				gf.MediaCaptureDeviceNumber = ((num < 1 | num > 5) ? 1 : num);
				gf.BackgroundPicture = gf.HeaderData[61];
				num = gf.ExtractNumericData(gf.HeaderData[62]);
				gf.BackgroundMode = (gf.ImageMode)((num < 0 | num > 2) ? 2 : num);
				num = gf.ExtractNumericData(gf.HeaderData[63]);
				gf.ShowVerticalAlign = ((num < 0 | num > 2) ? 1 : num);
				num = gf.ExtractNumericData(gf.HeaderData[64]);
				gf.ShowLeftMargin[0] = ((num < 0 | num > 40) ? 2 : num);
				num = gf.ExtractNumericData(gf.HeaderData[65]);
				gf.ShowRightMargin[0] = ((num < 0 | num > 40) ? 2 : num);
				num = gf.ExtractNumericData(gf.HeaderData[66]);
				gf.ShowBottomMargin[0] = ((num < 0 | num > 100) ? 0 : num);
				gf.ShowItemTransition = gf.GlobalImageCanvas.GetTransitionType(gf.HeaderData[72]);
				gf.ShowSlideTransition = gf.GlobalImageCanvas.GetTransitionType(gf.HeaderData[73]);
			}
			for (int i = 0; i < 8; i++)
			{
				gf.PB_ShowWords[i] = 1;
				gf.PB_WordsBold[i] = 0;
				gf.PB_WordsItalic[i] = 0;
				gf.PB_WordsUnderline[i] = 0;
				gf.PB_WordsSize[i] = 11;
				gf.PB_WordsColour[i] = gf.BlackScreenColour;
			}
			gf.PB_WordsSize[0] = 13;
			gf.PB_WordsSize[5] = 11;
			gf.PB_WordsSize[2] = 6;
			gf.PB_WordsBold[0] = 1;
			gf.PB_WordsBold[1] = 1;
			gf.PB_WordsItalic[4] = 1;
			gf.PB_WordsUnderline[0] = 1;
			gf.PB_ShowHeadings[0] = 1;
			gf.PB_ShowHeadings[1] = 1;
			gf.PB_ShowHeadings[2] = 0;
			gf.PB_ShowHeadings[3] = 0;
			gf.PB_LyricsPattern = 1;
			gf.PB_ShowSection = 2;
			gf.PB_ShowColumns = 2;
			gf.PB_PageSize = 0;
			gf.PB_Spacing[0] = 0;
			gf.PB_Spacing[1] = 2;
			gf.PB_ShowScreenBreaks = 1;
			gf.PB_OneSongPerPage = 0;
			gf.PB_CJKGroupStyle = gf.SortBy.Alpha;
			for (int i = 0; i < 8; i++)
			{
				int num2 = 101 + i * 5;
				num = gf.ExtractNumericData(gf.HeaderData[num2]);
				gf.PB_ShowWords[i] = ((num < 0) ? 1 : gf.GetBitValue(num, 1));
				if (num < 0)
				{
					num = 0;
				}
				if (i < 6)
				{
					gf.PB_WordsBold[i] = gf.GetBitValue(num, 2);
					gf.PB_WordsItalic[i] = gf.GetBitValue(num, 3);
					gf.PB_WordsUnderline[i] = gf.GetBitValue(num, 4);
					num = gf.ExtractNumericData(gf.HeaderData[num2 + 1]);
					gf.PB_WordsSize[i] = ((num < 4 | num > 72) ? gf.PB_WordsSize[i] : num);
					num = gf.ExtractNumericData(gf.HeaderData[num2 + 2]);
					gf.PB_WordsColour[i] = ((gf.HeaderData[num2 + 2] == "" | !gf.ValidateColour(num)) ? gf.BlackScreenColour : Color.FromArgb(Convert.ToInt32(num)));
				}
				else
				{
					gf.PB_WordsBold[i] = gf.PB_WordsBold[2];
					gf.PB_WordsItalic[i] = gf.PB_WordsItalic[2];
					gf.PB_WordsUnderline[i] = gf.PB_WordsUnderline[2];
					gf.PB_WordsSize[i] = gf.PB_WordsSize[2];
					gf.PB_WordsColour[i] = gf.PB_WordsColour[2];
				}
			}
			num = gf.ExtractNumericData(gf.HeaderData[151]);
			gf.PB_ShowHeadings[0] = gf.GetBitValue(num, 1);
			gf.PB_ShowHeadings[1] = gf.GetBitValue(num, 2);
			gf.PB_ShowHeadings[2] = gf.GetBitValue(num, 3);
			gf.PB_ShowHeadings[3] = gf.GetBitValue(num, 4);
			num = gf.ExtractNumericData(gf.HeaderData[153]);
			gf.PB_LyricsPattern = ((num < 0 | num > 1) ? 1 : num);
			num = gf.ExtractNumericData(gf.HeaderData[154]);
			gf.PB_ShowSection = ((num < 0 | num > 2) ? 2 : num);
			num = gf.ExtractNumericData(gf.HeaderData[155]);
			gf.PB_ShowColumns = ((num < 1 | num > 2) ? 2 : num);
			num = gf.ExtractNumericData(gf.HeaderData[156]);
			gf.PB_PageSize = ((num < 0 | num > 1) ? 0 : num);
			num = gf.ExtractNumericData(gf.HeaderData[170]);
			gf.PB_Spacing[0] = ((num < 0 | num > 5) ? 0 : num);
			num = gf.ExtractNumericData(gf.HeaderData[171]);
			gf.PB_Spacing[1] = ((num < 1 | num > 20) ? 2 : num);
			num = gf.ExtractNumericData(gf.HeaderData[172]);
			gf.PB_ShowScreenBreaks = ((num < 0 | num > 1) ? 1 : num);
			num = gf.ExtractNumericData(gf.HeaderData[173]);
			gf.PB_OneSongPerPage = ((num < 0 | num > 1) ? 0 : num);
			num = gf.ExtractNumericData(gf.HeaderData[174]);
			gf.PB_CJKGroupStyle = (gf.SortBy)((num < 0 | num > 1) ? 0 : num);
			num = gf.ExtractNumericData(gf.HeaderData[180]);
			gf.PB_ShowNotations = gf.GetBitValue(num, 1);
			gf.PB_ShowTiming = gf.GetBitValue(num, 2);
			gf.PB_ShowKey = gf.GetBitValue(num, 3);
			gf.PB_ShowCapo = gf.GetBitValue(num, 4);
			gf.PB_CapoZero = ((num < 0) ? 0 : gf.GetBitValue(num, 5));
		}
		public static int ExtractNumericData(string InString)
		{
			int result;
			if (InString == "")
			{
				result = -1;
			}
			else
			{
				try
				{
					int num = int.Parse(InString);
					result = num;
				}
				catch
				{
					result = -1;
				}
			}
			return result;
		}
		public static bool ValidateColour(int InNumber)
		{
			bool result;
			try
			{
				Color color = Color.FromArgb(Convert.ToInt32(InNumber));
				result = true;
			}
			catch
			{
				result = false;
			}
			return result;
		}
		public static int GetSelectedIndex(ListView InListView)
		{
			string text = null;
			return gf.GetSelectedIndex(InListView, ref text, "");
		}
		public static int GetSelectedIndex(ListView InListView, ref string OutString)
		{
			return gf.GetSelectedIndex(InListView, ref OutString, "");
		}
		public static int GetSelectedIndex(ListView InListView, ref string OutString, string InString)
		{
			return gf.GetSelectedIndex(InListView, ref OutString, InString, 0);
		}
		public static int GetSelectedIndex(ListView InListView, ref string OutString, string InString, int ColumnText)
		{
			int result;
			if (InListView.SelectedItems.Count == 0)
			{
				if (InListView.Items.Count > 0 && InListView.Items[0].Selected)
				{
					result = 0;
				}
				else
				{
					if (InString != "")
					{
						MessageBox.Show("Please select a song from the " + InString + " to edit");
					}
					result = -1;
				}
			}
			else
			{
				IEnumerator enumerator = InListView.SelectedItems.GetEnumerator();
				try
				{
					if (enumerator.MoveNext())
					{
						ListViewItem listViewItem = (ListViewItem)enumerator.Current;
						if (OutString != null)
						{
							OutString = listViewItem.SubItems[ColumnText].Text;
						}
						result = InListView.Items.IndexOf(listViewItem);
						return result;
					}
				}
				finally
				{
					IDisposable disposable = enumerator as IDisposable;
					if (disposable != null)
					{
						disposable.Dispose();
					}
				}
				result = -1;
			}
			return result;
		}
		public static string RemoveMusicSym(string InString)
		{
			string result;
			if (gf.Right(InString, gf.MusicSymLen) == " <#>")
			{
				result = gf.Left(InString, InString.Length - gf.MusicSymLen);
			}
			else
			{
				result = InString;
			}
			return result;
		}
		public static void SizeLaunchScreen()
		{
			if (gf.OutputMonitorNumber == 0 & gf.DMAlwaysUse)
			{
				gf.OutputMonitorNumber = 1;
			}
			gf.GetScreenNumber(ref gf.OutputMonitorNumber, ref gf.LS_Top, ref gf.LS_Left, ref gf.LS_Width, ref gf.LS_Height, -1);
			if (gf.DMOption == 0)
			{
				if (gf.OutputMonitorNumber > 0)
				{
					gf.DualMonitorMode = true;
					gf.OutputMonitorText = "Dual Monitor Mode";
				}
				else
				{
					gf.DualMonitorMode = false;
					gf.OutputMonitorText = "Single Monitor Mode";
				}
			}
			else
			{
				gf.LS_Top = gf.DMOption1Top;
				gf.LS_Left = gf.DMOption1Left;
				gf.LS_Width = gf.DMOption1Width;
				gf.LS_Height = gf.DMOption1Height;
				gf.DualMonitorMode = !gf.DMOption1AsSingleMonitor;
				gf.OutputMonitorText = "Custom Monitor Mode";
			}
			if (gf.LS_Height >= 768)
			{
				gf.Buffer_LS_Height = gf.LS_Height;
				gf.Buffer_LS_Width = gf.LS_Width;
			}
			else
			{
				float num = 768f / (float)gf.LS_Height;
				gf.Buffer_LS_Height = 768;
				gf.Buffer_LS_Width = (int)((float)gf.LS_Width * num);
			}
			gf.ShowTopBorderSize = (int)((double)gf.Buffer_LS_Height * gf.TopBorderFactor);
			gf.ShowBottomBorderSize = (int)((double)gf.Buffer_LS_Height * gf.BottomBorderFactor);
			gf.AdjustedOutlineThreshold = gf.OutlineFontSizeThreshold * gf.Buffer_LS_Width / 960;
			if (gf.LyricsMonitorNumber == 0 & gf.LMAlwaysUse)
			{
				gf.LyricsMonitorNumber = 1;
			}
			gf.GetScreenNumber(ref gf.LyricsMonitorNumber, ref gf.LM_Top, ref gf.LM_Left, ref gf.LM_Width, ref gf.LM_Height, (gf.DMOption == 0) ? gf.OutputMonitorNumber : -1);
			if (gf.LMOption == 1)
			{
				gf.LM_Top = gf.LMOption1Top;
				gf.LM_Left = gf.LMOption1Left;
				gf.LM_Width = gf.LMOption1Width;
				gf.LM_Height = gf.LMOption1Height;
			}
		}
		public static int GetScreenInfo(int InMonitor, ref int OutTop, ref int OutLeft, ref int OutWidth, ref int OutHeight)
		{
			return gf.GetScreenNumber(ref InMonitor, ref OutTop, ref OutLeft, ref OutWidth, ref OutHeight, -1);
		}
		public static int GetMaxScreen()
		{
			Screen[] allScreens = Screen.AllScreens;
			int num = allScreens.Length;
			int num2 = 20000;
			int num3 = 0;
			for (int i = 0; i < num; i++)
			{
				if (allScreens[i].Bounds.Height < num2 & allScreens[i].Bounds.Width < num2)
				{
					num3++;
				}
			}
			return num3;
		}
		public static int GetScreenNumber(ref int InMonitor, int SkipMonitor)
		{
			int num = 0;
			int num2 = 0;
			int num3 = 0;
			int num4 = 0;
			return gf.GetScreenNumber(ref InMonitor, ref num, ref num2, ref num3, ref num4, SkipMonitor);
		}
		public static int GetScreenNumber(ref int InMonitor, ref int t, ref int l, ref int w, ref int h, int SkipMonitor)
		{
			Screen[] allScreens = Screen.AllScreens;
			int num = allScreens.Length;
			int num2 = 20000;
			int num3 = -1;
			for (int i = 0; i < num; i++)
			{
				if (allScreens[i].Primary)
				{
					num3 = i;
					i = num;
				}
			}
			if (num3 < 0)
			{
				num3 = 0;
			}
			int num4;
			if (InMonitor == 0)
			{
				num4 = num3;
			}
			else
			{
				if (InMonitor < num & InMonitor != SkipMonitor)
				{
					if (allScreens[InMonitor].Bounds.Height < num2 & allScreens[InMonitor].Bounds.Width < num2)
					{
						num4 = InMonitor;
						goto IL_144;
					}
				}
				for (int i = 0; i < num; i++)
				{
					if (i != num3 & allScreens[i].Bounds.Height < num2 & allScreens[i].Bounds.Width < num2 & InMonitor != SkipMonitor)
					{
						InMonitor = i;
						num4 = i;
						goto IL_144;
					}
				}
				InMonitor = 0;
				num4 = 0;
				InMonitor = 0;
			}
			IL_144:
			if (num4 >= num)
			{
				num4 = num3;
			}
			try
			{
				t = allScreens[num4].Bounds.Top;
				l = allScreens[num4].Bounds.Left;
				h = allScreens[num4].Bounds.Height;
				w = h * 4 / 3;
			}
			catch
			{
				num4 = 0;
				t = allScreens[num4].Bounds.Top;
				l = allScreens[num4].Bounds.Left;
				h = allScreens[num4].Bounds.Height;
				w = h * 4 / 3;
			}
			return num4;
		}
		public static void ResetShowRunningSettings()
		{
			gf.ShowRunning_ShowDataDisplayMode = 0;
			gf.ShowRunning_ShowSongHeadings = 0;
			gf.ShowRunning_ShowLyrics = 0;
			gf.ShowRunning_UseShadowFont = 0;
			gf.ShowRunning_UseOutlineFont = 0;
			gf.ShowRunning_ShowNotations = 0;
			gf.ShowRunning_ShowInterlace = 0;
			gf.ShowRunning_ShowVerticalAlign = 0;
		}
		public static void SetListViewColumns(ListView InListView, int NumberofCol)
		{
			InListView.Clear();
			InListView.View = View.Details;
			for (int i = 0; i < NumberofCol; i++)
			{
				InListView.Columns.Add(i.ToString());
			}
		}
		public static void LoadDBFormatString(ref gf.SongSettings InItem)
		{
			try
			{
				string fullSearchString = "select * from SONG where songid=" + InItem.ItemID;
				Recordset recordSet = gf.GetRecordSet(gf.ConnectStringMainDB, fullSearchString);
				if (recordSet != null && !recordSet.EOF)
				{
					InItem.Format.DBStoredFormat = gf.GetDataString(recordSet, "FORMATDATA");
				}
			}
			catch
			{
			}
		}
		public static void LoadIndividualData(ref gf.SongSettings InItem, string InIDString, string InFormatString, int StartingSlide)
		{
			string text = "";
			gf.LoadIndividualData(ref InItem, InIDString, InFormatString, StartingSlide, ref text);
		}
		public static void LoadIndividualData(ref gf.SongSettings InItem, string InIDString, string InFormatString, int StartingSlide, ref string InTitle)
		{
			string a = gf.Left(InIDString, 1);
			InItem.ItemID = gf.Mid(InIDString, 1);
			string itemID = InItem.ItemID;
			if (a == "D")
			{
				InItem.Type = "D";
				try
				{
					string fullSearchString = "select * from SONG where songid=" + InItem.ItemID;
					Recordset recordSet = gf.GetRecordSet(gf.ConnectStringMainDB, fullSearchString);
					if (recordSet != null && !recordSet.EOF)
					{
						InItem.Title = gf.GetDataString(recordSet, "Title_1");
						InItem.Title2 = gf.GetDataString(recordSet, "Title_2");
						InItem.SongNumber = gf.GetDataInt(recordSet, "song_number");
						InItem.CompleteLyrics = gf.GetDataString(recordSet, "Lyrics");
						InItem.FolderNo = gf.GetDataInt(recordSet, "FolderNo");
						InItem.FontSizeFactor = 100;
						InItem.Writer = gf.GetDataString(recordSet, "Writer");
						InItem.Copyright = gf.GetDataString(recordSet, "Copyright");
						InItem.Format.FormatString = InFormatString;
						InItem.Format.DBStoredFormat = gf.GetDataString(recordSet, "FORMATDATA");
						InItem.Show_LicAdminInfo1 = gf.GetDataString(recordSet, "LICENCE_ADMIN1");
						InItem.Show_LicAdminInfo2 = gf.GetDataString(recordSet, "LICENCE_ADMIN2");
						InItem.In_LicAdminInfo1 = InItem.Show_LicAdminInfo1;
						InItem.In_LicAdminInfo2 = InItem.Show_LicAdminInfo2;
						gf.LoadLicAdminDisplayInfo(ref InItem.Show_LicAdminInfo1, ref InItem.Show_LicAdminInfo2);
						InItem.Notations = gf.GetDataString(recordSet, "msc");
						InItem.Capo = gf.GetDataInt(recordSet, "capo", true);
						InItem.CurSlide = StartingSlide;
						InItem.SongSequence = gf.GetDataString(recordSet, "Sequence");
						InItem.SongOriginalLoadedSequence = InItem.SongSequence;
						InItem.Book_Reference = gf.GetDataString(recordSet, "Book_Reference");
						InItem.User_Reference = gf.GetDataString(recordSet, "User_Reference");
						InItem.Timing = gf.GetDataString(recordSet, "timing");
						InItem.MusicKey = gf.GetDataString(recordSet, "key");
						InItem.Category = gf.GetDataString(recordSet, "category");
						InItem.RotateString = gf.ExtractSettings(gf.GetDataString(recordSet, "SETTINGS"), gf.SettingsCategory.RotateString);
						gf.GetRotationStyle(ref InItem);
						if (gf.ListViewNotations == null | InItem.LyricsAndNotationsList == null)
						{
							InItem.CompleteLyrics = "";
						}
					}
				}
				catch
				{
				}
			}
			else
			{
				if (a == "P")
				{
					InItem.Type = "P";
					InItem.Title = gf.GetDisplayNameOnly(ref itemID, false);
					InItem.CurSlide = StartingSlide;
					InItem.Path = gf.Mid(InIDString, 1);
				}
				else
				{
					if (a == "B")
					{
						string text = InIDString;
						gf.ExtractOneInfo(ref text, ';');
						int num = gf.LookUpBibleVersionNumber(gf.ExtractOneInfo(ref text, ';'));
						int num2 = gf.LookUpBibleVersionNumber(gf.ExtractOneInfo(ref text, ';'));
						InItem.Type = "B";
						if (num >= 0)
						{
							InItem.Type = "B";
							InItem.FolderNo = gf.StringToInt(gf.HB_Versions[num, 5]);
							InItem.FontSizeFactor = gf.StringToInt(gf.HB_Versions[num, 6]);
							InItem.CompleteLyrics = gf.LoadSelectedBibleVerses(InItem.ItemID);
							InItem.Copyright = gf.HB_Versions[num, 3];
							InItem.Show_BookName = (gf.Left(InItem.ItemID, 1) == "1");
							int num3 = InTitle.IndexOf("(");
							if (num3 > 0)
							{
								InTitle = gf.Trim(gf.Left(InTitle, num3 - 1));
							}
							if (num2 < 0)
							{
								InItem.Title = InTitle + " (" + gf.HB_Versions[num, 1] + ")";
								InItem.HBR2_FolderNo = InItem.FolderNo;
								InItem.HBR2_FontSizeFactor = InItem.FontSizeFactor;
							}
							else
							{
								InItem.Title = string.Concat(new string[]
								{
									InTitle,
									" (",
									gf.HB_Versions[num, 1],
									"/",
									gf.HB_Versions[num2, 1],
									")"
								});
								InItem.HBR2_FolderNo = gf.StringToInt(gf.HB_Versions[num2, 5]);
								InItem.HBR2_FontSizeFactor = gf.StringToInt(gf.HB_Versions[num2, 6]);
								gf.SongSettings expr_4C6 = InItem;
								expr_4C6.Copyright = expr_4C6.Copyright + "/" + gf.HB_Versions[num2, 3];
							}
							InItem.Format.FormatString = InFormatString;
							gf.LoadLicAdminDisplayInfo(ref InItem.Show_LicAdminInfo1, ref InItem.Show_LicAdminInfo2);
							InItem.Capo = -1;
							InItem.CurSlide = StartingSlide;
							InTitle = InItem.Title;
						}
					}
					else
					{
						if (a == "T")
						{
							InItem.Type = "T";
							InItem.Title = gf.GetDisplayNameOnly(ref itemID, false);
							InItem.Type = "T";
							InItem.CompleteLyrics = gf.LoadTextFile(itemID);
							InItem.Format.FormatString = InFormatString;
							InItem.Capo = -1;
							InItem.CurSlide = StartingSlide;
							InItem.Path = gf.Mid(InIDString, 1);
						}
						else
						{
							if (a == "I")
							{
								InItem.Type = "I";
								string[] array = new string[255];
								gf.LoadInfoFile(itemID, ref InItem, ref array);
								InItem.CurSlide = StartingSlide;
								InItem.Path = gf.Mid(InIDString, 1);
							}
							else
							{
								if (a == "W")
								{
									InItem.Type = "W";
									InItem.Title = gf.GetDisplayNameOnly(ref itemID, false);
									InItem.Type = "W";
									InItem.CompleteLyrics = gf.GetOfficeDocContents(itemID);
									InItem.Format.FormatString = InFormatString;
									InItem.Capo = -1;
									InItem.CurSlide = StartingSlide;
									InItem.Path = gf.Mid(InIDString, 1);
								}
								else
								{
									if (a == "M")
									{
										InItem.Type = "M";
										InItem.Title = gf.GetDisplayNameOnly(ref itemID, false);
										InItem.Type = "M";
										InItem.CompleteLyrics = " ";
										InItem.Format.FormatString = InFormatString;
										InItem.Capo = -1;
										InItem.CurSlide = 1;
										InItem.Path = gf.Mid(InIDString, 1);
									}
									else
									{
										if (a == "G")
										{
											InItem.Type = "G";
											InItem.Title = "";
											InItem.Type = "G";
											InItem.CompleteLyrics = " ";
											InItem.Format.FormatString = gf.GapFormatString(ref InItem);
											InItem.Capo = -1;
											InItem.CurSlide = StartingSlide;
										}
									}
								}
							}
						}
					}
				}
			}
			InItem.OriginalNotations = InItem.Notations;
			if (InItem.CompleteLyrics == "")
			{
				InItem.CompleteLyrics = " ";
			}
		}
		private static string GapFormatString(ref gf.SongSettings InItem)
		{
			InItem.UseDefaultFormat = false;
			string result;
			switch (gf.GapItemOption)
			{
			case gf.GapType.Black:
				InItem.Format.ShowScreenColour[0] = gf.BlackScreenColour;
				InItem.Format.ShowScreenColour[1] = gf.BlackScreenColour;
				InItem.Format.ShowScreenStyle = 11;
				InItem.Format.BackgroundPicture = "";
				break;
			case gf.GapType.Default:
				InItem.Format.ShowScreenColour[0] = gf.ShowScreenColour[0];
				InItem.Format.ShowScreenColour[1] = gf.ShowScreenColour[1];
				InItem.Format.ShowScreenStyle = gf.ShowScreenStyle;
				InItem.Format.BackgroundPicture = gf.BackgroundPicture;
				InItem.Format.BackgroundMode = gf.BackgroundMode;
				break;
			case gf.GapType.User:
			{
				InItem.Format.BackgroundPicture = gf.GapItemLogoFile;
				string directoryName = Path.GetDirectoryName(InItem.Format.BackgroundPicture);
				if (directoryName == gf.RootEasiSlidesDir + "Images\\Tiles")
				{
					InItem.Format.BackgroundMode = gf.ImageMode.Tile;
				}
				else
				{
					InItem.Format.BackgroundMode = gf.ImageMode.BestFit;
				}
				break;
			}
			default:
				result = "";
				return result;
			}
			InItem.Format.ShowItemTransition = (gf.GapItemUseFade ? 15 : 0);
			InItem.Format.ShowSlideTransition = InItem.Format.ShowItemTransition;
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.Append(string.Concat(new object[]
			{
				Convert.ToString(26),
				"=",
				Convert.ToString(InItem.Format.ShowScreenColour[0].ToArgb()),
				'>'
			}));
			stringBuilder.Append(string.Concat(new object[]
			{
				Convert.ToString(27),
				"=",
				Convert.ToString(InItem.Format.ShowScreenColour[1].ToArgb()),
				'>'
			}));
			stringBuilder.Append(string.Concat(new object[]
			{
				Convert.ToString(28),
				"=",
				InItem.Format.ShowScreenStyle.ToString(),
				'>'
			}));
			stringBuilder.Append(string.Concat(new object[]
			{
				Convert.ToString(50),
				"=",
				Convert.ToString(InItem.Format.MediaOption),
				'>'
			}));
			stringBuilder.Append(string.Concat(new object[]
			{
				Convert.ToString(51),
				"=",
				InItem.Format.MediaLocation,
				'>'
			}));
			stringBuilder.Append(string.Concat(new object[]
			{
				Convert.ToString(52),
				"=",
				Convert.ToString(InItem.Format.MediaVolume),
				'>'
			}));
			stringBuilder.Append(string.Concat(new object[]
			{
				Convert.ToString(53),
				"=",
				Convert.ToString(InItem.Format.MediaBalance),
				'>'
			}));
			int num = InItem.Format.MediaMute + InItem.Format.MediaRepeat * 2 + InItem.Format.MediaWidescreen * 4;
			stringBuilder.Append(string.Concat(new object[]
			{
				Convert.ToString(54),
				"=",
				num.ToString(),
				'>'
			}));
			stringBuilder.Append(string.Concat(new object[]
			{
				Convert.ToString(55),
				"=",
				Convert.ToString(InItem.Format.MediaCaptureDeviceNumber),
				'>'
			}));
			stringBuilder.Append(string.Concat(new object[]
			{
				Convert.ToString(61),
				"=",
				InItem.Format.BackgroundPicture,
				'>'
			}));
			stringBuilder.Append(string.Concat(new object[]
			{
				Convert.ToString(62),
				"=",
				Convert.ToString((int)InItem.Format.BackgroundMode),
				'>'
			}));
			stringBuilder.Append(string.Concat(new object[]
			{
				Convert.ToString(72),
				"=",
				gf.tempScreen.GetTransitionText(InItem.Format.ShowItemTransition),
				'>'
			}));
			stringBuilder.Append(string.Concat(new object[]
			{
				Convert.ToString(73),
				"=",
				gf.tempScreen.GetTransitionText(InItem.Format.ShowSlideTransition),
				'>'
			}));
			result = stringBuilder.ToString();
			return result;
		}
		public static bool IsNewR2Format(string InLyrics)
		{
			InLyrics = InLyrics.Replace("\r\n", "\n");
			string[] array = InLyrics.Split(new string[]
			{
				gf.VerseSymbol[150]
			}, StringSplitOptions.RemoveEmptyEntries);
			bool result;
			if (InLyrics == "" | array.GetUpperBound(0) == 0 | array.GetUpperBound(0) > 1)
			{
				result = false;
			}
			else
			{
				if (array[1][0] == "\n"[0])
				{
					array[1] = gf.Mid(array[1], 1);
				}
				for (int i = 1; i <= 99; i++)
				{
					if (gf.Left(array[1], gf.VerseSymbol[i].Length) == gf.VerseSymbol[i])
					{
						result = true;
						return result;
					}
				}
				result = (gf.Left(array[1], gf.VerseSymbol[0].Length) == gf.VerseSymbol[0] || gf.Left(array[1], gf.VerseSymbol[100].Length) == gf.VerseSymbol[100] || gf.Left(array[1], gf.VerseSymbol[103].Length) == gf.VerseSymbol[103] || gf.Left(array[1], gf.VerseSymbol[101].Length) == gf.VerseSymbol[101] || gf.Left(array[1], gf.VerseSymbol[102].Length) == gf.VerseSymbol[102] || gf.Left(array[1], gf.VerseSymbol[111].Length) == gf.VerseSymbol[111] || gf.Left(array[1], gf.VerseSymbol[112].Length) == gf.VerseSymbol[112]);
			}
			return result;
		}
		public static void InitialiseIndividualData(ref gf.SongSettings InItem)
		{
			gf.InitialiseIndividualData(ref InItem, gf.GapMedia.None, "");
		}
		public static void InitialiseIndividualData(ref gf.SongSettings InItem, gf.GapMedia InGapMedia, string InType)
		{
			InItem.ItemID = "";
			InItem.PrevItemPP = (InItem.Type == "P");
			InItem.Type = "";
			InItem.SongNumber = 0;
			InItem.FolderNo = 0;
			InItem.CompleteLyrics = "";
			InItem.SongSequence = "";
			InItem.SongBasicSequence = "";
			InItem.SongOriginalLoadedSequence = "";
			InItem.Writer = "";
			InItem.Copyright = "";
			InItem.Capo = -1;
			InItem.Timing = "";
			InItem.MusicKey = "";
			InItem.OriginalNotations = "";
			InItem.Notations = "";
			InItem.Category = "";
			InItem.Show_LicAdminInfo1 = "";
			InItem.Show_LicAdminInfo2 = "";
			InItem.In_LicAdminInfo1 = "";
			InItem.In_LicAdminInfo2 = "";
			InItem.Book_Reference = "";
			InItem.User_Reference = "";
			InItem.HBR2_FolderNo = 0;
			InItem.HBR2_FontSizeFactor = 100;
			InItem.FontSizeFactor = 100;
			InItem.CurSlide = 0;
			InItem.TotalSlides = 0;
			InItem.Path = "";
			InItem.RotateString = "";
			InItem.RotateStyle = 1;
			InItem.RotateGap = 0;
			InItem.RotateTotal = 0;
			InItem.RotateTimings = "";
			InItem.RotateSequence = "";
			InItem.Format.ImageString = "";
			InItem.Format.TempImageFileName = "";
			InItem.FirstShowing = true;
			InItem.FolderName = "";
			InItem.PrevTitle = "";
			InItem.NextTitle = "";
			InItem.Format.FormatString = "";
			InItem.Format.DBStoredFormat = "";
			if (InGapMedia == gf.GapMedia.SessionMedia && gf.MediaOption == 1)
			{
				InGapMedia = gf.GapMedia.None;
			}
			switch (InGapMedia)
			{
			case gf.GapMedia.SameAsPrevious:
				InItem.Format.MediaOption = (InItem.UseDefaultFormat ? gf.MediaOption : InItem.Format.MediaOption);
				InItem.Format.MediaLocation = (InItem.UseDefaultFormat ? gf.MediaLocation : InItem.Format.MediaLocation);
				InItem.Format.MediaVolume = (InItem.UseDefaultFormat ? gf.MediaVolume : InItem.Format.MediaVolume);
				InItem.Format.MediaBalance = (InItem.UseDefaultFormat ? gf.MediaBalance : InItem.Format.MediaBalance);
				InItem.Format.MediaCaptureDeviceNumber = (InItem.UseDefaultFormat ? gf.MediaCaptureDeviceNumber : InItem.Format.MediaCaptureDeviceNumber);
				break;
			case gf.GapMedia.SessionMedia:
				InItem.Format.MediaOption = gf.MediaOption;
				InItem.Format.MediaLocation = gf.MediaLocation;
				InItem.Format.MediaVolume = gf.MediaVolume;
				InItem.Format.MediaBalance = gf.MediaBalance;
				InItem.Format.MediaCaptureDeviceNumber = gf.MediaCaptureDeviceNumber;
				break;
			default:
				InItem.Title = "";
				InItem.Title2 = "";
				InItem.Format.MediaOption = 0;
				InItem.Format.MediaLocation = "";
				InItem.Format.MediaVolume = 0;
				InItem.Format.MediaBalance = 0;
				InItem.Format.MediaCaptureDeviceNumber = 0;
				break;
			}
			InItem.UseDefaultFormat = true;
		}
		public static int LookUpBibleVersionNumber(string InFileName)
		{
			int result;
			if (gf.HB_TotalVersions < 1)
			{
				result = -1;
			}
			else
			{
				for (int i = 0; i < gf.HB_TotalVersions; i++)
				{
					if (gf.HB_Versions[i, 4] == gf.BibleDir + InFileName)
					{
						result = i;
						return result;
					}
				}
				result = -1;
			}
			return result;
		}
		public static void LoadLicAdminDisplayInfo(ref string AdminInfo1, ref string AdminInfo2)
		{
			string text = "";
			string text2 = "";
			if (AdminInfo1 == "")
			{
				text = gf.LicAdmin_List[0, 2];
			}
			else
			{
				for (int i = 2; i <= 9; i++)
				{
					if (gf.LicAdmin_List[i, 0] != "")
					{
						if (AdminInfo1 == gf.LicAdmin_List[i, 0])
						{
							text = gf.LicAdmin_List[i, 2];
							i = 9;
						}
					}
				}
			}
			if (AdminInfo2 == "")
			{
				text2 = gf.LicAdmin_List[0, 2];
			}
			else
			{
				for (int i = 2; i <= 9; i++)
				{
					if (gf.LicAdmin_List[i, 0] != "")
					{
						if (AdminInfo2 == gf.LicAdmin_List[i, 0])
						{
							text2 = gf.LicAdmin_List[i, 2];
							i = 9;
						}
					}
				}
			}
			if (text != "")
			{
				AdminInfo1 = text;
			}
			if (text != text2)
			{
				AdminInfo2 = text2;
			}
		}
		public static int IncrementChord(ref int CurPos, int TransposeTo)
		{
			int num = CurPos + TransposeTo;
			if (num >= 12)
			{
				num %= 12;
			}
			else
			{
				if (num < 0)
				{
					num += 12 * (1 - num / 12);
				}
			}
			return num;
		}
		public void LoadIndividualFormatData(ref gf.SongSettings InItem)
		{
			gf.LoadIndividualFormatData(ref InItem, "");
		}
		public static string LoadSelectedBibleVerses(string InFullBibleString)
		{
			string result;
			try
			{
				bool flag = gf.StringToInt(gf.ExtractOneInfo(ref InFullBibleString, ';')) > 0;
				string[] array = new string[2];
				int[] array2 = new int[2];
				string[] array3 = new string[2];
				array[0] = gf.ExtractOneInfo(ref InFullBibleString, ';');
				array2[0] = gf.LookUpBibleVersionNumber(array[0]);
				array[1] = gf.ExtractOneInfo(ref InFullBibleString, ';');
				array2[1] = gf.LookUpBibleVersionNumber(array[1]);
				array3[0] = InFullBibleString;
				array3[1] = InFullBibleString;
				StringBuilder stringBuilder = new StringBuilder();
				for (int i = 0; i <= ((array2[1] >= 0) ? 1 : 0); i++)
				{
					string text = gf.ConnectStringDef + gf.HB_Versions[array2[i], 4];
					bool noneSpacingText = gf.PartialWordSearch(array2[1]);
					if (i == 1)
					{
						stringBuilder.Append(gf.VerseSymbol[150] + "\n");
					}
					while (array3[i] != "")
					{
						int inBookNumber = gf.StringToInt(gf.ExtractOneInfo(ref array3[i], ';'));
						int chapterStart = gf.StringToInt(gf.ExtractOneInfo(ref array3[i], ';'));
						int verseStart = gf.StringToInt(gf.ExtractOneInfo(ref array3[i], ';'));
						int chapterEnd = gf.StringToInt(gf.ExtractOneInfo(ref array3[i], ';'));
						int verseEnd = gf.StringToInt(gf.ExtractOneInfo(ref array3[i], ';'));
						gf.LoadBiblePassages(array2[i], inBookNumber, ref stringBuilder, true, false, false, chapterStart, verseStart, chapterEnd, verseEnd, flag, noneSpacingText, flag, true);
						stringBuilder.Append("\n");
					}
				}
				result = stringBuilder.ToString();
			}
			catch
			{
				result = "";
			}
			return result;
		}
		public static void UpdatePosUpDowns(ref NumericUpDown Reg1_UpDown, ref NumericUpDown Reg2_UpDown, ref NumericUpDown RegBottom_UpDown, ref int Reg1_Value, ref int Reg2_Value, int RegBottom_Value)
		{
			if (Reg1_Value < 0)
			{
				Reg1_Value = 0;
			}
			if (Reg1_Value > 100)
			{
				Reg1_Value = 100;
			}
			if (Reg2_Value < Reg1_Value)
			{
				Reg2_Value = Reg1_Value;
			}
			if (Reg2_Value > 100)
			{
				Reg2_Value = 100;
			}
			if (RegBottom_Value + Reg1_Value > 100)
			{
				RegBottom_Value = 100 - Reg1_Value;
				Reg2_Value = Reg1_Value;
			}
			if (RegBottom_Value + Reg2_Value > 100)
			{
				Reg2_Value = 100 - RegBottom_Value;
			}
			Reg1_UpDown.Minimum = 0m;
			Reg1_UpDown.Maximum = 100m;
			Reg1_UpDown.Value = Reg1_Value;
			Reg1_UpDown.Maximum = 100 - RegBottom_Value;
			Reg2_UpDown.Minimum = Reg1_Value;
			Reg2_UpDown.Maximum = 100m;
			Reg2_UpDown.Value = Reg2_Value;
			Reg2_UpDown.Maximum = 100 - RegBottom_Value;
			RegBottom_UpDown.Minimum = 0m;
			RegBottom_UpDown.Maximum = 100m;
			RegBottom_UpDown.Value = RegBottom_Value;
		}
		public static void SetShowBackground(gf.SongSettings InItem, ref ImageTransitionControl InPic)
		{
			gf.SetShowBackground(InItem, ref InPic, true);
		}
		public static void SetShowBackground(gf.SongSettings InItem, ref ImageTransitionControl InPic, bool FallBackToDefault)
		{
			gf.ImageMode picMode = gf.ImageMode.Tile;
			string text = "";
			if (InItem.UseDefaultFormat)
			{
				if (File.Exists(gf.BackgroundPicture))
				{
					text = gf.BackgroundPicture;
				}
				picMode = gf.BackgroundMode;
			}
			else
			{
				string text2 = (InItem.Type == "I") ? InItem.Format.TempImageFileName : InItem.Format.BackgroundPicture;
				if (File.Exists(text2))
				{
					text = text2;
					picMode = InItem.Format.BackgroundMode;
				}
				else
				{
					if (InItem.Type == "I" && InItem.Format.TempImageFileName == "")
					{
						InItem.Format.ShowScreenColour[0] = gf.ShowScreenColour[0];
						InItem.Format.ShowScreenColour[1] = gf.ShowScreenColour[1];
						InItem.Format.ShowScreenStyle = gf.ShowScreenStyle;
					}
				}
			}
			if (text == "")
			{
				gf.SetColoursFormat(InItem, ref InPic);
			}
			else
			{
				gf.SetImageFormat(ref InPic, text, picMode, false);
			}
		}
		public static void SetColoursFormat(gf.SongSettings InItem, ref ImageTransitionControl InPic)
		{
			gf.SetColoursFormat(InItem, ref InPic, false);
		}
		public static void SetColoursFormat(gf.SongSettings InItem, ref ImageTransitionControl InPic, bool SetTransparent)
		{
			if (SetTransparent)
			{
				string text = "";
				Image image = new Bitmap(gf.Buffer_LS_Width, gf.Buffer_LS_Height);
				Graphics graphics = Graphics.FromImage(image);
				gf.BackPattern.Clear(ref graphics, gf.TransparentColour);
				InPic.NewBackgroundPicture = image;
				InPic.NewTextImage = InPic.NewBackgroundPicture;
				InPic.TransitBackPictureAction = ImageTransitionControl.BackPicturesTransition.None;
				InPic.CurrentBackgroundPicture = (Image)InPic.NewBackgroundPicture.Clone();
			}
			else
			{
				if (InItem.UseDefaultFormat)
				{
					if (InPic.NewBackgroundPicture != null)
					{
						InPic.CurrentBackgroundPicture = (Image)InPic.NewBackgroundPicture.Clone();
					}
					else
					{
						InPic.CurrentBackgroundPicture = InPic.BackgroundImage;
						InPic.CurrentTextImage = InPic.BackgroundImage;
						InPic.CurrentCombinedImage = InPic.BackgroundImage;
						InPic.NewTextImage = InPic.BackgroundImage;
					}
					InPic.NewBackgroundPicture = InPic.BackgroundImage;
					if (InPic.BackgroundID == gf.DefaultBackgroundID)
					{
						InPic.TransitBackPictureAction = ImageTransitionControl.BackPicturesTransition.None;
					}
					else
					{
						InPic.TransitBackPictureAction = ImageTransitionControl.BackPicturesTransition.CurrentOnly;
					}
					InPic.BackgroundID = gf.DefaultBackgroundID;
				}
				else
				{
					string text = "";
					Image image = new Bitmap(gf.Buffer_LS_Width, gf.Buffer_LS_Height);
					Graphics graphics = Graphics.FromImage(image);
					gf.BackPattern.Fill(ref graphics, InItem.Format.ShowScreenColour[0], InItem.Format.ShowScreenColour[1], InItem.Format.ShowScreenStyle, gf.Buffer_LS_Width, gf.Buffer_LS_Height, ref text);
					if (InPic.NewBackgroundPicture != null)
					{
						InPic.CurrentBackgroundPicture = (Image)InPic.NewBackgroundPicture.Clone();
					}
					else
					{
						InPic.CurrentBackgroundPicture = InPic.BackgroundImage;
						InPic.CurrentTextImage = InPic.BackgroundImage;
						InPic.CurrentCombinedImage = InPic.BackgroundImage;
						InPic.NewTextImage = InPic.BackgroundImage;
					}
					InPic.NewBackgroundPicture = image;
					if (InPic.BackgroundID == text)
					{
						InPic.TransitBackPictureAction = ImageTransitionControl.BackPicturesTransition.None;
					}
					else
					{
						if (InPic.BackgroundID == gf.DefaultBackgroundID)
						{
							InPic.TransitBackPictureAction = ImageTransitionControl.BackPicturesTransition.NewOnly;
						}
						else
						{
							if (text == gf.DefaultBackgroundID)
							{
								InPic.TransitBackPictureAction = ImageTransitionControl.BackPicturesTransition.CurrentOnly;
							}
							else
							{
								InPic.TransitBackPictureAction = ImageTransitionControl.BackPicturesTransition.BothBackgrounds;
							}
						}
					}
					InPic.BackgroundID = text;
				}
			}
			try
			{
				if (InPic.CurrentBackgroundPicture == null)
				{
					InPic.CurrentBackgroundPicture = (Image)InPic.NewBackgroundPicture.Clone();
				}
				if (InPic.CurrentTextImage == null)
				{
					InPic.CurrentTextImage = (Image)InPic.NewBackgroundPicture.Clone();
				}
				if (InPic.CurrentCombinedImage == null)
				{
					InPic.CurrentCombinedImage = (Image)InPic.NewBackgroundPicture.Clone();
				}
				if (InPic.NewBackgroundPicture == null)
				{
					InPic.NewBackgroundPicture = (Image)InPic.NewBackgroundPicture.Clone();
				}
				if (InPic.NewTextImage == null)
				{
					InPic.NewTextImage = (Image)InPic.NewBackgroundPicture.Clone();
				}
				if (InPic.NewCombinedImage == null)
				{
					InPic.NewCombinedImage = (Image)InPic.NewBackgroundPicture.Clone();
				}
			}
			catch
			{
			}
		}
		public static void SetImageFormat(ref ImageTransitionControl InPic, string File_Name, gf.ImageMode PicMode, bool SetTransparent)
		{
			Image image = new Bitmap(gf.Buffer_LS_Width, gf.Buffer_LS_Height);
			Graphics graphics = Graphics.FromImage(image);
			if (InPic.BackgroundID != "")
			{
				if (InPic.BackgroundID == gf.DefaultBackgroundID)
				{
					InPic.TransitBackPictureAction = ImageTransitionControl.BackPicturesTransition.NewOnly;
				}
				else
				{
					InPic.TransitBackPictureAction = ImageTransitionControl.BackPicturesTransition.BothBackgrounds;
				}
			}
			else
			{
				if (InPic.ImageFileName == File_Name & InPic.PicMode == (int)PicMode)
				{
					InPic.TransitBackPictureAction = ImageTransitionControl.BackPicturesTransition.None;
				}
				else
				{
					InPic.TransitBackPictureAction = ImageTransitionControl.BackPicturesTransition.BothBackgrounds;
				}
			}
			InPic.BackgroundID = "";
			Image image2 = Image.FromFile(File_Name);
			InPic.ImageFileName = File_Name;
			InPic.PicMode = (int)PicMode;
			double num = (double)image2.Width / (double)image2.Height;
			if (!(InPic.Width <= 0 | InPic.Height <= 0))
			{
				double num2 = (double)InPic.Width / (double)InPic.Height;
				if (PicMode == gf.ImageMode.Centre)
				{
					int i = 0;
					int j = 0;
					int num3 = image2.Width;
					int num4 = image2.Height;
					int x;
					int num5;
					int num6;
					int y;
					if (num2 < num)
					{
						x = 0;
						num5 = image.Width;
						num6 = (int)((double)num5 / num);
						y = (image.Height - num6) / 2;
					}
					else
					{
						y = 0;
						num6 = image.Height;
						num5 = (int)((double)num6 * num);
						x = (image.Width - num5) / 2;
					}
					graphics.DrawImage(image2, new Rectangle(x, y, num5, num6), new Rectangle(i, j, num3, num4), GraphicsUnit.Pixel);
				}
				else
				{
					if (PicMode == gf.ImageMode.Tile)
					{
						int num3 = image2.Width;
						int num4 = image2.Height;
						for (int i = 0; i <= image.Width / num3; i++)
						{
							for (int j = 0; j <= image.Height / num4; j++)
							{
								int x = i * num3;
								int y = j * num4;
								graphics.DrawImage(image2, new Rectangle(x, y, num3, num4), new Rectangle(0, 0, num3, num4), GraphicsUnit.Pixel);
							}
						}
					}
					else
					{
						int x = 0;
						int y = 0;
						int num5 = image.Width;
						int num6 = image.Height;
						int i;
						int j;
						int num3;
						int num4;
						if (num2 < num)
						{
							j = 0;
							num4 = image2.Height;
							num3 = (int)((double)num4 * num2);
							i = (image2.Width - num3) / 2;
						}
						else
						{
							i = 0;
							num3 = image2.Width;
							num4 = (int)((double)num3 / num2);
							j = (image2.Height - num4) / 2;
						}
						graphics.DrawImage(image2, new Rectangle(x, y, num5, num6), new Rectangle(i, j, num3, num4), GraphicsUnit.Pixel);
					}
				}
				if (InPic.NewBackgroundPicture != null)
				{
					InPic.CurrentBackgroundPicture = (Image)InPic.NewBackgroundPicture.Clone();
				}
				else
				{
					InPic.CurrentBackgroundPicture = image;
				}
				InPic.NewBackgroundPicture = image;
			}
		}
		public static string GetSlideContents(gf.SongSettings InItem, int CurSlide, int RegionNumber, Font InFont, bool PreviewNotations)
		{
			int[,] slide = InItem.Slide;
			int num = (RegionNumber == 0) ? 1 : 3;
			int num2 = (RegionNumber == 0) ? 2 : 4;
			string text = "";
			string str = "";
			int num3 = 0;
			gf.tbWorkspace.WordWrap = false;
			gf.tbTempSpace.WordWrap = false;
			if (PreviewNotations)
			{
				if (slide[CurSlide, num] <= slide[CurSlide, num2])
				{
					bool flag = false;
					for (int i = slide[CurSlide, num]; i <= slide[CurSlide, num2]; i++)
					{
						if (InItem.LyricsAndNotationsList.Items[i].SubItems[3].Text != "")
						{
							flag = true;
							i = slide[CurSlide, num2] + 1;
						}
					}
					string text2 = "";
					for (int i = slide[CurSlide, num]; i <= slide[CurSlide, num2]; i++)
					{
						text = text + InItem.LyricsAndNotationsList.Items[i].SubItems[2].Text + "\n";
						if (flag)
						{
							object obj = text2;
							text2 = string.Concat(new object[]
							{
								obj,
								"(",
								Convert.ToInt32(num3),
								';',
								InItem.LyricsAndNotationsList.Items[i].SubItems[3].Text,
								")"
							});
						}
						num3++;
					}
					text = gf.CombineLyricsAndNotations(text, text2, InFont, InFont, ref gf.tbWorkspace, ref gf.tbTempSpace) + "\n";
				}
			}
			else
			{
				if (slide[CurSlide, num] <= slide[CurSlide, num2])
				{
					for (int i = slide[CurSlide, num]; i <= slide[CurSlide, num2]; i++)
					{
						str = InItem.LyricsAndNotationsList.Items[i].SubItems[2].Text + "\n";
						gf.SubstituteDashes(ref str, 0);
						text += str;
					}
				}
			}
			if (InItem.Type == "B")
			{
				text = text.Replace('\u0098'.ToString(), "");
			}
			return gf.TrimEnd(text) + "\n";
		}
		public static string OldGetSlideContents(gf.SongSettings InItem, int CurSlide, int RegionNumber, Font InFont, bool PreviewNotations)
		{
			int[,] slide = InItem.Slide;
			int num = (RegionNumber == 0) ? 1 : 3;
			int num2 = (RegionNumber == 0) ? 2 : 4;
			string text = "";
			if (PreviewNotations)
			{
				if (slide[CurSlide, num] <= slide[CurSlide, num2])
				{
					bool flag = false;
					for (int i = slide[CurSlide, num]; i <= slide[CurSlide, num2]; i++)
					{
						if (InItem.LyricsAndNotationsList.Items[i].SubItems[3].Text != "")
						{
							flag = true;
							i = slide[CurSlide, num2] + 1;
						}
					}
					for (int i = slide[CurSlide, num]; i <= slide[CurSlide, num2]; i++)
					{
						if (flag)
						{
							text = text + gf.CombineLyricsAndNotations(InItem.LyricsAndNotationsList.Items[i].SubItems[2].Text, InItem.LyricsAndNotationsList.Items[i].SubItems[3].Text, InFont, InFont, ref gf.tbWorkspace, ref gf.tbTempSpace) + "\n";
						}
						text = text + InItem.LyricsAndNotationsList.Items[i].SubItems[2].Text + "\n";
					}
				}
			}
			else
			{
				if (slide[CurSlide, num] <= slide[CurSlide, num2])
				{
					for (int i = slide[CurSlide, num]; i <= slide[CurSlide, num2]; i++)
					{
						text = text + InItem.LyricsAndNotationsList.Items[i].SubItems[2].Text + "\n";
					}
				}
			}
			if (InItem.Type == "B")
			{
				text = text.Replace('\u0098'.ToString(), "");
			}
			return text;
		}
		public static string FormatNotationString(ListView InListView, string InString, string InNotation, Font MainFont, Font NotationsFont)
		{
			Graphics graphics = InListView.CreateGraphics();
			string text = "i";
			int num = (int)graphics.MeasureString(text, NotationsFont, 1000, StringFormat.GenericTypographic).Width;
			string text2 = text;
			string text3 = "";
			int num2 = 0;
			string text4 = gf.ExtractOneInfo(ref InNotation, ';');
			string text5 = gf.ExtractOneInfo(ref InNotation, ';');
			while (text4 != "-1" & text5 != "-1")
			{
				string text6 = gf.Left(InString, Convert.ToInt32(text5));
				if (gf.Right(text6, 1) == " ")
				{
					text6 = gf.Left(text6, text6.Length - 1) + text;
				}
				int num3 = (int)graphics.MeasureString(text6, MainFont, 32000, StringFormat.GenericDefault).Width;
				while (graphics.MeasureString(text2, NotationsFont, 32000, StringFormat.GenericDefault).Width < (float)(num3 + num))
				{
					text2 = gf.Left(text2, text2.Length - 1) + " " + text;
					num2++;
				}
				if (text2.Length - 2 >= 0 && text2[text2.Length - 2].ToString() != " ")
				{
					text2 = gf.Left(text2, text2.Length - 1) + " " + text4 + text;
				}
				else
				{
					text2 = gf.Left(text2, text2.Length - 1) + text4 + text;
				}
				if (gf.PB_PrinterSpaces > 0)
				{
					int num4 = num2 / 12;
					for (int i = 1; i <= num2 + num4; i++)
					{
						text3 += " ";
					}
					text3 += text4;
				}
				num2 = 0;
				text4 = gf.ExtractOneInfo(ref InNotation, ';');
				text5 = gf.ExtractOneInfo(ref InNotation, ';');
			}
			if (gf.Right(text2, 1) == text)
			{
				text2 = gf.Left(text2, text2.Length - 1);
			}
			string result;
			if (text2 != "")
			{
				if (gf.PB_PrinterSpaces > 0)
				{
					result = text3;
				}
				else
				{
					result = text2;
				}
			}
			else
			{
				result = " ";
			}
			return result;
		}
		public static string RTFFormatNotationString(string InText, string InNotationString, Font MainFont, Font NotationFont)
		{
			string text = "";
			string text2 = "";
			gf.tbWorkspace.Font = MainFont;
			gf.tbWorkspace.WordWrap = false;
			gf.tbWorkspace.Text = InText;
			gf.tbTempSpace.Font = NotationFont;
			gf.tbTempSpace.WordWrap = false;
			gf.tbTempSpace.Text = "";
			while (InNotationString != "")
			{
				text = InNotationString;
				string text3 = gf.ExtractOneInfo(ref text, ';');
				int inCurPos = Convert.ToInt32(gf.ExtractOneInfo(ref text, ';'));
				InNotationString = text;
				int associatedLyricsLineCurPosX = gf.GetAssociatedLyricsLineCurPosX(ref gf.tbWorkspace, inCurPos, 0);
				while (gf.GetAssociatedLyricsLineCurPosX(ref gf.tbTempSpace, gf.tbTempSpace.Text.Length - 1) < associatedLyricsLineCurPosX - 1)
				{
					text2 += " ";
					gf.tbTempSpace.Text = text2;
					gf.MarkSelectedRTB(ref gf.tbTempSpace, 0, gf.tbTempSpace.Text.Length, 2, MainFont, NotationFont);
				}
				text2 += ((text2.Length > 1 & gf.Right(text2, 1) != " ") ? (" " + text3) : text3);
				gf.tbTempSpace.Text = text2;
				gf.MarkSelectedRTB(ref gf.tbTempSpace, 0, gf.tbTempSpace.Text.Length, 2, MainFont, NotationFont);
			}
			return text2;
		}
		public static int GetAssociatedLyricsLineCurPosX(ref RichTextBox IntextBox, int InCurPos)
		{
			return gf.GetAssociatedLyricsLineCurPosX(ref IntextBox, InCurPos, 0);
		}
		public static int GetAssociatedLyricsLineCurPosX(ref RichTextBox IntextBox, int InCurPos, int LyricsCurPosMin)
		{
			return gf.GetAssociatedLyricsLineCurPosX(ref IntextBox, InCurPos, LyricsCurPosMin, 64000);
		}
		public static int GetAssociatedLyricsLineCurPosX(ref RichTextBox IntextBox, int InCurPos, int LyricsCurPosMin, int LyricsCurPosMax)
		{
			if (InCurPos < 0)
			{
				InCurPos = 0;
			}
			int result;
			if (InCurPos > LyricsCurPosMax - LyricsCurPosMin + 1)
			{
				Point positionFromCharIndex = IntextBox.GetPositionFromCharIndex(LyricsCurPosMax - LyricsCurPosMin + 1);
				Point positionFromCharIndex2 = IntextBox.GetPositionFromCharIndex(LyricsCurPosMax - LyricsCurPosMin);
				result = positionFromCharIndex.X + (positionFromCharIndex.X - positionFromCharIndex2.X);
			}
			else
			{
				result = IntextBox.GetPositionFromCharIndex(InCurPos + LyricsCurPosMin).X;
			}
			return result;
		}
		public static string CombineLyricsAndNotations(string InText, string InNotations, Font MainFont, Font NotationFont, ref RichTextBox InWorkspace, ref RichTextBox InTempSpace)
		{
			string result;
			if (InNotations == "" | InText == "")
			{
				result = InText;
			}
			else
			{
				StringBuilder stringBuilder = new StringBuilder();
				InWorkspace.Text = InText;
				gf.MarkSelectedRTB(ref InWorkspace, 0, InWorkspace.Text.Length, 0, MainFont, NotationFont);
				int num = gf.CountLf(InWorkspace.Text);
				int lyricsCurPosMin = 0;
				int lyricsCurPosMax = 0;
				string text = "";
				int num2 = gf.ListNotationData(InNotations, ref gf.NotationsArray, num);
				for (int i = 0; i < num; i++)
				{
					if (num2 > 0)
					{
						if (gf.NotationsArray[i] != "")
						{
							gf.GetMinMaxfromTextBox(InWorkspace, i, ref lyricsCurPosMin, ref lyricsCurPosMax);
							InTempSpace.Text = "";
							string text2 = "";
							while (gf.NotationsArray[i].Length > 0)
							{
								text = gf.NotationsArray[i];
								string text3 = gf.ExtractOneInfo(ref text, ';');
								int inCurPos = Convert.ToInt32(gf.ExtractOneInfo(ref text, ';'));
								gf.NotationsArray[i] = text;
								int associatedLyricsLineCurPosX = gf.GetAssociatedLyricsLineCurPosX(ref InWorkspace, inCurPos, lyricsCurPosMin, lyricsCurPosMax);
								while (gf.GetAssociatedLyricsLineCurPosX(ref InTempSpace, InTempSpace.Text.Length - 1) < associatedLyricsLineCurPosX - 4)
								{
									text2 += " ";
									InTempSpace.Text = text2;
									gf.MarkSelectedRTB(ref InTempSpace, 0, InTempSpace.Text.Length, 2, MainFont, NotationFont);
								}
								text2 += ((text2.Length > 1 & gf.Right(text2, 1) != " ") ? (" " + text3) : text3);
								InTempSpace.Text = text2;
								gf.MarkSelectedRTB(ref InTempSpace, 0, InTempSpace.Text.Length, 2, MainFont, NotationFont);
							}
							stringBuilder.Append(InTempSpace.Text + " »\n");
						}
					}
					stringBuilder.Append(InWorkspace.Lines[i] + "\n");
				}
				if (gf.Right(stringBuilder.ToString(), 1) == "\n")
				{
					result = gf.Left(stringBuilder.ToString(), stringBuilder.Length - 1);
				}
				else
				{
					result = stringBuilder.ToString();
				}
			}
			return result;
		}
		public static void GetMinMaxfromTextBox(RichTextBox InBox, int InLineNumber, ref int InMin, ref int InMax)
		{
			string text = InBox.Text + "\n";
			InMax = -1;
			for (int i = 0; i <= InLineNumber; i++)
			{
				InMin = InMax + 1;
				InMax = text.IndexOf("\n", InMin);
				if (InMax < 0)
				{
					i = InLineNumber;
				}
			}
			InMax--;
		}
		public static void FormatDisplayLyrics(ref gf.SongSettings InItem, bool PrepareSlides, bool UseStoredSequence)
		{
			int num = InItem.UseDefaultFormat ? gf.ShowNotations : InItem.Format.ShowNotations;
			int num2 = InItem.UseDefaultFormat ? ((gf.ShowCapoZero == 1) ? gf.IncrementChord(ref InItem.Capo, 0) : 0) : InItem.Format.TransposeOffset;
			ListViewItem listViewItem = new ListViewItem();
			InItem.CompleteLyrics = InItem.CompleteLyrics.Replace("\r\n", "\n");
			int num3 = gf.CountLf(InItem.CompleteLyrics);
			if (InItem != null)
			{
				if (InItem.Capo < 0)
				{
					InItem.Capo = -1;
				}
			}
			if (gf.ShowRunning_ShowNotations == 1)
			{
				num = ((num > 0) ? 0 : 1);
			}
			if (num == 1)
			{
				if (num2 > 0)
				{
					InItem.Notations = gf.TransposeNotations(InItem.OriginalNotations, InItem.Format.PreviousTransposeOffset, num2, InItem.MusicKey);
				}
				else
				{
					InItem.Notations = InItem.OriginalNotations;
				}
			}
			for (int i = 0; i < 160; i++)
			{
				InItem.VersePresent[i] = false;
				InItem.VerseLineLoc[i, 0] = -1;
				InItem.VerseLineLoc[i, 1] = -1;
				InItem.VerseLineLoc[i, 2] = -1;
				InItem.VerseLineLoc[i, 3] = -1;
				InItem.VerseLineLoc[i, 4] = -1;
			}
			ListView listView = gf.ExtractLyrics(InItem.CompleteLyrics, InItem.Notations);
			InItem.LyricsAndNotationsList.Items.Clear();
			int num4 = -1;
			if (InItem.RotateStyle == 2)
			{
				InItem.SongSequence = InItem.RotateSequence;
			}
			InItem.SongBasicSequence = "";
			for (int i = 0; i < listView.Items.Count; i++)
			{
				int j = gf.StringToInt(listView.Items[i].Text);
				if (!InItem.VersePresent[j])
				{
					InItem.VersePresent[j] = true;
					if (num4 != j)
					{
						gf.SongSettings expr_22E = InItem;
						expr_22E.SongBasicSequence += (char)j;
						num4 = j;
					}
				}
			}
			for (int i = 0; i < 160; i++)
			{
				if (InItem.VersePresent[i])
				{
					for (int k = 0; k < listView.Items.Count; k++)
					{
						if (listView.Items[k].SubItems[0].Text == i.ToString() && listView.Items[k].SubItems[1].Text == "1")
						{
							string text = i.ToString();
							listViewItem = InItem.LyricsAndNotationsList.Items.Add(text);
							listViewItem.SubItems.Add("1");
							listViewItem.SubItems.Add(listView.Items[k].SubItems[2].Text);
							listViewItem.SubItems.Add(listView.Items[k].SubItems[3].Text);
							listViewItem.SubItems.Add("");
						}
					}
					for (int k = 0; k < listView.Items.Count; k++)
					{
						if (listView.Items[k].SubItems[0].Text == i.ToString() && listView.Items[k].SubItems[1].Text == "2")
						{
							string text = i.ToString();
							listViewItem = InItem.LyricsAndNotationsList.Items.Add(text);
							listViewItem.SubItems.Add("2");
							listViewItem.SubItems.Add(listView.Items[k].SubItems[2].Text);
							listViewItem.SubItems.Add(listView.Items[k].SubItems[3].Text);
							listViewItem.SubItems.Add("");
							InItem.VersePresent[150] = true;
						}
					}
				}
			}
			for (int i = InItem.LyricsAndNotationsList.Items.Count - 1; i >= 0; i--)
			{
				if (InItem.LyricsAndNotationsList.Items[i].SubItems[2].Text == "")
				{
					InItem.LyricsAndNotationsList.Items[i].Remove();
				}
				else
				{
					i = 0;
				}
			}
			for (int i = InItem.LyricsAndNotationsList.Items.Count - 1; i >= 1; i--)
			{
				if (InItem.LyricsAndNotationsList.Items[i].SubItems[2].Text == "")
				{
					if (InItem.LyricsAndNotationsList.Items[i - 1].SubItems[2].Text == "")
					{
						InItem.LyricsAndNotationsList.Items[i].Remove();
					}
				}
			}
			if (InItem.LyricsAndNotationsList.Items.Count > 0)
			{
				if (InItem.LyricsAndNotationsList.Items[0].SubItems[2].Text == "")
				{
					InItem.LyricsAndNotationsList.Items[0].Remove();
				}
			}
			for (int j = 0; j < 160; j++)
			{
				if (InItem.VersePresent[j])
				{
					for (int i = 0; i < InItem.LyricsAndNotationsList.Items.Count; i++)
					{
						num4 = gf.StringToInt(InItem.LyricsAndNotationsList.Items[i].SubItems[0].Text);
						int num5 = gf.StringToInt(InItem.LyricsAndNotationsList.Items[i].SubItems[1].Text);
						if (j == num4)
						{
							if (InItem.VerseLineLoc[j, num5 * 2 - 1] < 0)
							{
								InItem.VerseLineLoc[j, num5 * 2 - 1] = i;
							}
							InItem.VerseLineLoc[j, num5 * 2] = i;
						}
					}
				}
			}
			if (PrepareSlides)
			{
				if (UseStoredSequence)
				{
					gf.ValidateSequence(ref InItem);
				}
				else
				{
					InItem.SongSequence = InItem.SongBasicSequence;
				}
				gf.BuildSlides(InItem, InItem.LyricsAndNotationsList, ref InItem.SongSequence, ref InItem.TotalSlides, ref InItem.SongVerses, ref InItem.ChorusSlides, ref InItem.Slide, num);
				if (InItem != null)
				{
				}
			}
			else
			{
				InItem.SongSequence = InItem.SongBasicSequence;
			}
		}
		public static void ValidateSequence(ref gf.SongSettings InItem)
		{
			if (InItem.SongSequence == null)
			{
				InItem.SongSequence = "";
			}
			string text = "";
			for (int i = 0; i < InItem.SongSequence.Length; i++)
			{
				if (InItem.VersePresent[(int)InItem.SongSequence[i]])
				{
					text += gf.Mid(InItem.SongSequence, i, 1);
				}
			}
			if (text.Length > 0)
			{
				InItem.SongSequence = text;
			}
			else
			{
				InItem.SongSequence = InItem.SongBasicSequence;
			}
		}
		public static void GetMinMaxfromTextString(string InString, int InLineNumber, ref int InMin, ref int InMax)
		{
			if (InString == "")
			{
				InMin = -1;
				InMax = -1;
			}
			string text = InString + "\n";
			InMax = -1;
			for (int i = 0; i <= InLineNumber; i++)
			{
				InMin = InMax + 1;
				InMax = text.IndexOf("\n", InMin);
				if (InMax < 0)
				{
					InMin = -1;
					InMax = -1;
					i = InLineNumber;
				}
			}
			InMax--;
		}
		public static int CountLf(string InText)
		{
			int num = 0;
			InText += "\n";
			int length = InText.Length;
			for (int i = 0; i < length; i++)
			{
				if (gf.Mid(InText, i, 1) == "\n")
				{
					num++;
				}
			}
			return num;
		}
		public static int GetVerseIndicator(string InString)
		{
			int result;
			for (int i = 0; i <= 150; i++)
			{
				if (i < 13 | (i >= 100 & i <= 112) | i == 150)
				{
					if (InString.IndexOf(gf.VerseSymbol[i]) >= 0)
					{
						result = i;
						return result;
					}
				}
			}
			result = -1;
			return result;
		}
		public static string TransposeNotations(string InNotationsData, int PreviousTransposeTo, int TransposeTo, string StoredMusicKey)
		{
			string notationString = "";
			string text = "";
			int i = gf.ExtractOneNotationsLine(ref InNotationsData, ref notationString);
			if (PreviousTransposeTo > TransposeTo)
			{
				TransposeTo -= 12;
			}
			int flatSharpKey = gf.TransposeKey(ref StoredMusicKey, TransposeTo);
			while (i >= 0)
			{
				object obj = text;
				text = string.Concat(new object[]
				{
					obj,
					"(",
					Convert.ToString(i),
					';'
				});
				text = text + gf.TransposeOneNotationString(notationString, TransposeTo, flatSharpKey) + ")";
				i = Convert.ToInt32(gf.ExtractOneNotationsLine(ref InNotationsData, ref notationString));
			}
			return text;
		}
		public static string TransposeOneNotationString(string NotationString, int TransposeTo, int FlatSharpKey)
		{
			string text = "";
			while (NotationString != "")
			{
				string text2 = gf.TransposeChord(gf.ExtractOneInfo(ref NotationString, ';'), TransposeTo, FlatSharpKey);
				string text3 = gf.ExtractOneInfo(ref NotationString, ';');
				object obj = text;
				text = string.Concat(new object[]
				{
					obj,
					text2,
					';',
					text3,
					';'
				});
			}
			return text;
		}
		public static int ListNotationData(string InString, ref string[] NotationsArray, int MaxLineCount)
		{
			string text = "";
			int num = 0;
			for (int i = 0; i <= MaxLineCount; i++)
			{
				NotationsArray[i] = "";
			}
			int j = gf.ExtractOneNotationsLine(ref InString, ref text);
			while (j >= 0)
			{
				NotationsArray[j] = text;
				j = gf.ExtractOneNotationsLine(ref InString, ref text);
				num++;
			}
			return num;
		}
		public static int ExtractOneNotationsLine(ref string InString, ref string ResultString)
		{
			int result;
			if (InString == null | InString == "")
			{
				ResultString = "";
				result = -1;
			}
			else
			{
				string text = "";
				int num = InString.IndexOf("(");
				if (num < 0)
				{
					result = -1;
				}
				else
				{
					int num2 = InString.IndexOf(")", num);
					if (num2 < num)
					{
						result = -1;
					}
					else
					{
						num++;
						text += gf.Mid(InString, num, num2 - num);
						InString = gf.Mid(InString, num2 + ")".Length);
						int num3 = gf.StringToInt(gf.ExtractOneInfo(ref text, ';'));
						ResultString = text;
						result = num3;
					}
				}
			}
			return result;
		}
		public static void ChangeNotationLineNumber(ref string InOneNotationLine, int InNewLineNumber)
		{
			if (InOneNotationLine.Length > 0)
			{
				string text = InOneNotationLine;
				string text2 = gf.ExtractOneInfo(ref text, ';');
				int num = Convert.ToInt32(gf.ExtractOneInfo(ref text, ';'));
				if (text2 != "-1" & num >= 0)
				{
					InOneNotationLine = string.Concat(new object[]
					{
						text2,
						';',
						InNewLineNumber,
						';',
						text
					});
				}
			}
		}
		public static void BuildSlides(gf.SongSettings InItem, ListView LyricsLists, ref string SongSequence, ref int CurSongMaxSlides, ref int[] SongVerses, ref int[] ChorusSlides, ref int[,] Slide, int InShowNotations)
		{
			int[,] array = new int[10000, 4];
			int folderNo = 1;
			for (int i = 0; i <= 9; i++)
			{
				SongVerses[i] = 0;
				ChorusSlides[i] = 0;
			}
			CurSongMaxSlides = 0;
			if (InItem != null)
			{
				InItem.Verse2Present = InItem.VersePresent[2];
				folderNo = InItem.FolderNo;
			}
			Slide[0, 3] = -1;
			for (int i = 0; i < SongSequence.Length; i++)
			{
				int num = (int)SongSequence[i];
				bool lastSubScreen = false;
				if (InItem.VersePresent[num])
				{
					int verseScreenCount = gf.GetVerseScreenCount(LyricsLists, InItem.VerseLineLoc[num, 1], InItem.VerseLineLoc[num, 2]);
					if (verseScreenCount > 0)
					{
						try
						{
							for (int j = 1; j <= verseScreenCount; j++)
							{
								int verseScreenLoc = gf.GetVerseScreenLoc(LyricsLists, InItem.VerseLineLoc[num, 1], InItem.VerseLineLoc[num, 2], j);
								if (verseScreenLoc >= 0)
								{
									CurSongMaxSlides++;
									if (j == 1)
									{
										Slide[CurSongMaxSlides, 0] = num;
									}
									else
									{
										Slide[CurSongMaxSlides, 0] = -1;
									}
									Slide[CurSongMaxSlides, 1] = verseScreenLoc;
									Slide[CurSongMaxSlides, 2] = gf.GetVerseScreenEndLoc(LyricsLists, verseScreenLoc, InItem.VerseLineLoc[num, 2]);
									Slide[CurSongMaxSlides, 3] = -1;
									Slide[CurSongMaxSlides, 4] = -1;
									array[0, 0] = 1;
									array[1, 1] = Slide[CurSongMaxSlides, 1];
									array[1, 2] = Slide[CurSongMaxSlides, 2];
									if (InItem != null)
									{
										if (Slide[CurSongMaxSlides, 2] >= 0)
										{
											if (InItem.SplitScreens)
											{
												if (gf.GetScreensRequired(InItem, InItem.Lyrics[0], ref LyricsLists, Slide[CurSongMaxSlides, 1], Slide[CurSongMaxSlides, 2], ref array, InItem.VersePresent[150], 0, folderNo, InShowNotations) > 1)
												{
													CurSongMaxSlides--;
													for (int k = 1; k <= array[0, 0]; k++)
													{
														CurSongMaxSlides++;
														if (j == 1 & k == 1)
														{
															Slide[CurSongMaxSlides, 0] = num;
														}
														else
														{
															Slide[CurSongMaxSlides, 0] = -1;
														}
														Slide[CurSongMaxSlides, 1] = array[k, 1];
														Slide[CurSongMaxSlides, 2] = array[k, 2];
														Slide[CurSongMaxSlides, 3] = -1;
														Slide[CurSongMaxSlides, 4] = -1;
													}
												}
											}
										}
									}
									if (InItem.VerseLineLoc[num, 3] >= 0 & InItem.VerseLineLoc[num, 4] >= InItem.VerseLineLoc[num, 3])
									{
										Slide[0, 3] = 1;
										if (j == verseScreenCount)
										{
											lastSubScreen = true;
										}
										gf.BuildSlidesReg2(LyricsLists, InItem.VerseLineLoc[num, 3], InItem.VerseLineLoc[num, 4], ref Slide, ref CurSongMaxSlides, array, j, lastSubScreen);
									}
								}
							}
						}
						catch
						{
						}
					}
					else
					{
						try
						{
							Slide[0, 3] = 2;
							verseScreenCount = gf.GetVerseScreenCount(LyricsLists, InItem.VerseLineLoc[num, 3], InItem.VerseLineLoc[num, 4]);
							for (int j = 1; j <= verseScreenCount; j++)
							{
								int verseScreenLoc = gf.GetVerseScreenLoc(LyricsLists, InItem.VerseLineLoc[num, 3], InItem.VerseLineLoc[num, 4], j);
								if (verseScreenLoc >= 0)
								{
									CurSongMaxSlides++;
									if (j == 1)
									{
										Slide[CurSongMaxSlides, 0] = num;
									}
									else
									{
										Slide[CurSongMaxSlides, 0] = -1;
									}
									Slide[CurSongMaxSlides, 1] = -1;
									Slide[CurSongMaxSlides, 2] = -1;
									Slide[CurSongMaxSlides, 3] = verseScreenLoc;
									Slide[CurSongMaxSlides, 4] = gf.GetVerseScreenEndLoc(LyricsLists, verseScreenLoc, InItem.VerseLineLoc[num, 4]);
									array[0, 0] = 1;
									array[1, 1] = Slide[CurSongMaxSlides, 3];
									array[1, 2] = Slide[CurSongMaxSlides, 4];
									if (InItem != null)
									{
										if (Slide[CurSongMaxSlides, 4] >= 0)
										{
											if (InItem.SplitScreens)
											{
												if (gf.GetScreensRequired(InItem, InItem.Lyrics[1], ref LyricsLists, Slide[CurSongMaxSlides, 3], Slide[CurSongMaxSlides, 4], ref array, true, 1, folderNo, InShowNotations) > 1)
												{
													CurSongMaxSlides--;
													for (int k = 1; k <= array[0, 0]; k++)
													{
														CurSongMaxSlides++;
														if (k == 1)
														{
															Slide[CurSongMaxSlides, 0] = num;
														}
														else
														{
															Slide[CurSongMaxSlides, 0] = -1;
														}
														Slide[CurSongMaxSlides, 1] = -1;
														Slide[CurSongMaxSlides, 2] = -1;
														Slide[CurSongMaxSlides, 3] = array[k, 1];
														Slide[CurSongMaxSlides, 4] = array[k, 2];
													}
												}
											}
										}
									}
								}
							}
						}
						catch
						{
						}
					}
				}
			}
			try
			{
				int num2 = 1;
				for (int i = CurSongMaxSlides; i >= 1; i--)
				{
					if (Slide[i, 0] > 0 & Slide[i, 0] <= 9)
					{
						SongVerses[Slide[i, 0]] = i;
					}
					else
					{
						if (Slide[i, 0] == 0)
						{
							if (num2 <= 9)
							{
								SongVerses[0] = i;
								ChorusSlides[num2] = i;
								num2++;
							}
						}
					}
				}
			}
			catch
			{
			}
		}
		public static int GetVerseScreenCount(ListView LyricsLists, int StartLoc, int EndLoc)
		{
			int result;
			if (StartLoc > EndLoc | StartLoc < 0 | EndLoc < 0)
			{
				result = -1;
			}
			else
			{
				int num = 0;
				for (int i = StartLoc; i <= EndLoc; i++)
				{
					if (LyricsLists.Items[i].SubItems[2].Text == "" | i == EndLoc)
					{
						num++;
					}
				}
				result = num;
			}
			return result;
		}
		public static int GetVerseScreenLoc(ListView LyricsLists, int StartLoc, int EndLoc, int InScreenNumber)
		{
			int result;
			if (StartLoc > EndLoc)
			{
				result = -1;
			}
			else
			{
				if (StartLoc + 1 <= EndLoc && LyricsLists.Items[StartLoc].SubItems[2].Text == "")
				{
					StartLoc++;
				}
				int num = 1;
				int i = StartLoc;
				while (i <= EndLoc)
				{
					if (LyricsLists.Items[i].SubItems[2].Text == "")
					{
						num++;
					}
					if (InScreenNumber == num)
					{
						if (LyricsLists.Items[i].SubItems[2].Text != "")
						{
							result = i;
							return result;
						}
						if (i < EndLoc)
						{
							result = i + 1;
							return result;
						}
						result = -1;
						return result;
					}
					else
					{
						i++;
					}
				}
				result = -1;
			}
			return result;
		}
		public static int GetVerseScreenEndLoc(ListView LyricsLists, int StartLoc, int EndLoc)
		{
			int result;
			if (StartLoc > EndLoc)
			{
				result = -1;
			}
			else
			{
				if (StartLoc == EndLoc)
				{
					result = EndLoc;
				}
				else
				{
					if (LyricsLists.Items[StartLoc].SubItems[2].Text == "")
					{
						StartLoc++;
					}
					for (int i = StartLoc; i < EndLoc; i++)
					{
						if (LyricsLists.Items[i].SubItems[2].Text == "")
						{
							result = i - 1;
							return result;
						}
					}
					result = EndLoc;
				}
			}
			return result;
		}
		public static void BuildSlidesReg2(ListView LyricsLists, int StartLoc, int EndLoc, ref int[,] Slide, ref int CurSlideNumber, int[,] Reg1SubLoc, int InScreenNumber, bool LastSubScreen)
		{
			if (!(StartLoc > EndLoc | Reg1SubLoc[0, 0] < 1))
			{
				int num = gf.GetVerseScreenLoc(LyricsLists, StartLoc, EndLoc, InScreenNumber);
				if (num >= 0)
				{
					int verseScreenEndLoc = gf.GetVerseScreenEndLoc(LyricsLists, num, EndLoc);
					int num2 = num;
					for (int i = 1; i <= Reg1SubLoc[0, 0]; i++)
					{
						int num3 = CurSlideNumber - Reg1SubLoc[0, 0] + i;
						int num4 = Slide[num3, 2] - Slide[num3, 1] + 1;
						if (num4 > 0 & num2 >= 0)
						{
							Slide[num3, 3] = num2;
							if (num2 >= 0)
							{
								if (verseScreenEndLoc - num2 + 1 >= num4)
								{
									if (i == Reg1SubLoc[0, 0])
									{
										Slide[num3, 4] = verseScreenEndLoc;
										num2 = -1;
									}
									else
									{
										Slide[num3, 4] = num2 + num4 - 1;
										num2 += num4;
									}
								}
								else
								{
									Slide[num3, 4] = verseScreenEndLoc;
									num2 = -1;
								}
							}
						}
					}
					if (EndLoc > verseScreenEndLoc & LastSubScreen)
					{
						num = verseScreenEndLoc + 1;
						for (int j = 1; j <= gf.GetVerseScreenCount(LyricsLists, num, EndLoc); j++)
						{
							int verseScreenLoc = gf.GetVerseScreenLoc(LyricsLists, num, EndLoc, j);
							if (verseScreenLoc >= 0)
							{
								CurSlideNumber++;
								Slide[CurSlideNumber, 0] = -1;
								Slide[CurSlideNumber, 1] = -1;
								Slide[CurSlideNumber, 2] = -1;
								Slide[CurSlideNumber, 3] = verseScreenLoc;
								Slide[CurSlideNumber, 4] = gf.GetVerseScreenEndLoc(LyricsLists, verseScreenLoc, EndLoc);
							}
						}
					}
				}
			}
		}
		public static int GetScreensRequired(gf.SongSettings InItem, gf.SongSettings.SongLyrics InLyricsFormat, ref ListView LyricsLists, int StartLoc, int EndLoc, ref int[,] Reg1SubLoc, bool Region2Present, int RegionNumber, int FolderNo, int InShowNotations)
		{
			Graphics g = LyricsLists.CreateGraphics();
			int num = 0;
			Reg1SubLoc[0, 0] = num;
			ListViewItem listViewItem = new ListViewItem();
			int num2 = StartLoc;
			int num3 = EndLoc;
			while (gf.GetOneScreen(InItem, InLyricsFormat, ref LyricsLists, g, num2, ref num3, EndLoc, Region2Present, RegionNumber, FolderNo, InShowNotations) > 0)
			{
				num++;
				Reg1SubLoc[num, 1] = num2;
				Reg1SubLoc[num, 2] = num3;
				Reg1SubLoc[num, 3] = num3 - num2 + 1;
				Reg1SubLoc[0, 0] = num;
				num2 = num3 + 1;
				num3 = EndLoc;
			}
			return num;
		}
		public static int GetOneScreen(gf.SongSettings InItem, gf.SongSettings.SongLyrics InLyricsFormat, ref ListView LyricsLists, Graphics g, int startline, ref int endline, int EndLoc, bool Region2Present, int RegionNumber, int FolderNo, int InShowNotations)
		{
			return gf.GetOneScreen(InItem, InLyricsFormat, ref LyricsLists, g, startline, ref endline, EndLoc, Region2Present, RegionNumber, FolderNo, InShowNotations, false, false);
		}
		public static int GetOneScreen(gf.SongSettings InItem, gf.SongSettings.SongLyrics InLyricsFormat, ref ListView LyricsLists, Graphics g, int startline, ref int endline, int EndLoc, bool Region2Present, int RegionNumber, int FolderNo, int InShowNotations, bool FitAllIntoOneScreen, bool UseLargestFontSize)
		{
			int result;
			if (endline < startline)
			{
				result = 0;
			}
			else
			{
				Font mainFont = new Font(InLyricsFormat.Font.Name, InLyricsFormat.Font.Size, InLyricsFormat.Font.Style);
				SizeF layoutArea = new SizeF((float)InLyricsFormat.FS_Width, 32000f);
				string arg_65_0 = (RegionNumber == 0) ? "\n" : "";
				double num = gf.MainFontSpacingFactor[FolderNo, 0] + ((InShowNotations > 0) ? gf.NotationFontFactor : 0.0);
				int num2 = (int)((double)(Region2Present ? InLyricsFormat.FS_Height_R2Bound : InLyricsFormat.FS_Height) / num);
				string text = "";
				for (int i = startline; i <= endline; i++)
				{
					text = text + LyricsLists.Items[i].SubItems[2].Text + "\n";
				}
				if (text.Length > 1)
				{
					text = gf.Left(text, text.Length - 1);
				}
				if ((!gf.AutoTextOverflow || InItem.RotateStyle == 2) && InItem.Type != "B")
				{
					gf.ReduceFontToFit(g, text, ref mainFont, InLyricsFormat.FS_Width, num2, true);
				}
				int num3 = (int)g.MeasureString("A", InLyricsFormat.FS_Font, layoutArea).Height;
				int num4 = 0;
				for (int i = startline; i <= EndLoc; i++)
				{
					if (i == startline)
					{
						gf.ReduceFontToFit(g, LyricsLists.Items[i].SubItems[2].Text, ref mainFont, InLyricsFormat.FS_Width, num2, true);
					}
					num4 += gf.GetLinesRequiredAndAddBreakPlusFont(ref LyricsLists, mainFont, g, i, layoutArea.Width) * num3;
					if (num4 > num2 & ((gf.AutoTextOverflow & InItem.RotateStyle != 2) || InItem.Type == "B"))
					{
						endline = ((i > startline) ? (i - 1) : startline);
						result = 1;
						return result;
					}
				}
				endline = EndLoc;
				result = 1;
			}
			return result;
		}
		public static string ActionWordWrapSpacesAtStart(ref string InString)
		{
			string text = "";
			if (gf.WordWrapIgnoreStartSpaces > 0 && InString.Length > gf.WordWrapIgnoreStartSpaces)
			{
				string text2 = gf.Left(InString, gf.WordWrapIgnoreStartSpaces);
				for (int i = 0; i < text2.Length; i++)
				{
					if (text2[i].ToString() == " ")
					{
						text = text + i.ToString() + ';';
					}
				}
				text2 = text2.Replace(" ", "_");
				InString = text2 + gf.Mid(InString, gf.WordWrapIgnoreStartSpaces);
			}
			return text;
		}
		public static void ActionUndoWordWrapSpacesAtStart(ref string ExtractedText, ref string ReplacedLog)
		{
			int num = gf.StringToInt(gf.ExtractOneInfo(ref ReplacedLog, ';'));
			string text = ExtractedText;
			while (num < ExtractedText.Length && num >= 0)
			{
				text = text.Remove(num, 1);
				text = text.Insert(num, " ");
				num = gf.StringToInt(gf.ExtractOneInfo(ref ReplacedLog, ';'));
			}
			ExtractedText = text;
			if (num > ExtractedText.Length)
			{
				ReplacedLog = num.ToString() + ';' + ReplacedLog;
			}
			int num2 = num;
			text = "";
			while (ReplacedLog != "")
			{
				num = gf.StringToInt(gf.ExtractOneInfo(ref ReplacedLog, ';'));
				text = text + Convert.ToString(num - num2) + ';';
			}
			ReplacedLog = text;
		}
		public static int ReduceFontToFit(Graphics g, string InText, ref Font MainFont, int InWidth, int InHeight)
		{
			return gf.ReduceFontToFit(g, InText, ref MainFont, InWidth, InHeight, false);
		}
		public static int ReduceFontToFit(Graphics g, string InText, ref Font MainFont, int InWidth, int InHeight, bool MultiLine)
		{
			SizeF layoutArea = new SizeF((float)InWidth, 32000f);
			if (MultiLine)
			{
				while (g.MeasureString(InText, MainFont, layoutArea).Height > (float)InHeight & MainFont.Size > 1f)
				{
					MainFont = new Font(MainFont.Name, MainFont.Size - 1f, MainFont.Style);
				}
			}
			else
			{
				while (MainFont.Size > 1f && (g.MeasureString(InText, MainFont).Width > (float)InWidth || g.MeasureString(InText, MainFont).Height > (float)InHeight))
				{
					MainFont = new Font(MainFont.Name, MainFont.Size - 1f, MainFont.Style);
				}
			}
			return (int)g.MeasureString(InText, MainFont).Height;
		}
		public static int IncreaseFontToLargest(Graphics g, string InText, ref Font MainFont, int InWidth, int InHeight)
		{
			bool flag = false;
			return gf.IncreaseFontToLargest(g, InText, ref MainFont, InWidth, InHeight, ref flag);
		}
		public static int IncreaseFontToLargest(Graphics g, string InText, ref Font MainFont, int InWidth, int InHeight, ref bool OnlyOneDisplayLine)
		{
			gf.ReduceFontToFit(g, InText, ref MainFont, InWidth, InHeight);
			SizeF layoutArea = new SizeF((float)InWidth, 32000f);
			while (g.MeasureString(InText, MainFont, layoutArea).Height < (float)InHeight & MainFont.Size <= 100f)
			{
				MainFont = new Font(MainFont.Name, MainFont.Size + 1f, MainFont.Style);
			}
			MainFont = new Font(MainFont.Name, MainFont.Size - 4f, MainFont.Style);
			int result = (int)g.MeasureString(InText, MainFont, layoutArea).Height;
			if (g.MeasureString(InText, MainFont).Width < (float)InWidth)
			{
				OnlyOneDisplayLine = true;
			}
			return result;
		}
		public static int GetLinesRequiredAndAddBreakPlusFont(ref ListView LyricsLists, Font MainFont, Graphics g, int LyricsIndex, float InWidth)
		{
			string text = LyricsLists.Items[LyricsIndex].SubItems[2].Text;
			gf.ActionWordWrapSpacesAtStart(ref text);
			int length = text.Length;
			int result;
			if (length == 0)
			{
				result = 0;
			}
			else
			{
				int num = 1;
				int num2 = 0;
				bool flag = false;
				int num3 = 1;
				int num4 = 0;
				LyricsLists.Items[LyricsIndex].SubItems[4].Text = "";
				for (int i = 1; i <= length; i++)
				{
					if (gf.Mid(text, i, 1) == " ")
					{
						num2 = i;
						flag = true;
					}
					else
					{
						if (g.MeasureString(gf.Mid(text, num, i - num + 1), MainFont).Width > InWidth)
						{
							if (flag)
							{
								num4++;
								num = num2 + 1;
								ListViewItem.ListViewSubItem expr_102 = LyricsLists.Items[LyricsIndex].SubItems[4];
								expr_102.Text = expr_102.Text + Convert.ToString(num - num3) + '>';
								num3 = num;
								flag = false;
							}
							else
							{
								num4++;
								num = i;
								ListViewItem.ListViewSubItem expr_14D = LyricsLists.Items[LyricsIndex].SubItems[4];
								expr_14D.Text = expr_14D.Text + Convert.ToString(num - num3) + '>';
								num3 = num;
							}
						}
					}
				}
				ListViewItem.ListViewSubItem expr_1A1 = LyricsLists.Items[LyricsIndex].SubItems[4];
				expr_1A1.Text = expr_1A1.Text + Convert.ToString(length - num3 + 1) + '>';
				LyricsLists.Items[LyricsIndex].SubItems[4].Text = string.Concat(new object[]
				{
					Convert.ToString(num4 + 1),
					'>',
					Convert.ToString(MainFont.Size),
					'>',
					LyricsLists.Items[LyricsIndex].SubItems[4].Text
				});
				gf.LyricsArray[LyricsIndex, 2] = LyricsLists.Items[LyricsIndex].SubItems[4].Text;
				result = num4 + 1;
			}
			return result;
		}
		public static bool ShowDBSlide(ref gf.SongSettings InItem, ref ImageTransitionControl PInPictureBox, ref ImageTransitionControl OInPictureBox, bool DoActiveIndicator, ImageTransitionControl.TransitionAction TransitionAction)
		{
			bool result;
			if (InItem.OutputStyleScreen)
			{
				result = gf.ShowDBSlide(ref InItem, ref OInPictureBox, DoActiveIndicator, TransitionAction, false);
			}
			else
			{
				result = gf.ShowDBSlide(ref InItem, ref PInPictureBox, DoActiveIndicator, TransitionAction, false);
			}
			return result;
		}
		public static bool ShowDBSlide(ref gf.SongSettings InItem, ref ImageTransitionControl InPictureBox, bool DoActiveIndicator, ImageTransitionControl.TransitionAction TransitionAction, bool RedoBackground)
		{
			int arg_1D_0 = InItem.UseDefaultFormat ? gf.ShowSongHeadingsAlign : InItem.Format.ShowSongHeadingsAlign;
			int num = InItem.UseDefaultFormat ? gf.ShowNotations : InItem.Format.ShowNotations;
			int inShowInterlace = InItem.UseDefaultFormat ? gf.ShowInterlace : InItem.Format.ShowInterlace;
			int num2 = InItem.UseDefaultFormat ? gf.ShowVerticalAlign : InItem.Format.ShowVerticalAlign;
			int transitionType = InItem.UseDefaultFormat ? gf.ShowItemTransition : InItem.Format.ShowItemTransition;
			int transitionType2 = InItem.UseDefaultFormat ? gf.ShowSlideTransition : InItem.Format.ShowSlideTransition;
			InItem.Format.ShowLyrics = (InItem.UseDefaultFormat ? gf.ShowLyrics : InItem.Format.ShowLyrics);
			InItem.Format.ShowSongHeadings = (InItem.UseDefaultFormat ? gf.ShowSongHeadings : InItem.Format.ShowSongHeadings);
			InItem.Format.ShowSongHeadingsAlign = (InItem.UseDefaultFormat ? gf.ShowSongHeadingsAlign : InItem.Format.ShowSongHeadingsAlign);
			int inUseShadowFont = InItem.UseDefaultFormat ? gf.UseShadowFont : InItem.Format.UseShadowFont;
			int inUseOutlineFont = InItem.UseDefaultFormat ? gf.UseOutlineFont : InItem.Format.UseOutlineFont;
			int inHideDisplayPanel = InItem.UseDefaultFormat ? ((gf.ShowDataDisplayMode > 0) ? 0 : 1) : InItem.Format.HideDisplayPanel;
			InItem.CurSlide = ((InItem.CurSlide > 0) ? ((InItem.CurSlide > InItem.TotalSlides) ? InItem.TotalSlides : InItem.CurSlide) : 1);
			if (InItem.CurSlide > 0)
			{
				if (InItem.Slide[InItem.CurSlide, 0] >= 0)
				{
					if (InItem.CurSlide > 1)
					{
						if (InItem.Slide[InItem.CurSlide, 0] == 0)
						{
							InItem.Lyrics[2].Text = gf.FolderLyricsHeading[InItem.FolderNo, 1];
						}
						else
						{
							if (InItem.Slide[InItem.CurSlide, 0] == 102)
							{
								InItem.Lyrics[2].Text = gf.FolderLyricsHeading[InItem.FolderNo, 1] + ((gf.FolderLyricsHeading[InItem.FolderNo, 1] != "") ? " (2)" : "");
							}
							else
							{
								if (InItem.Slide[InItem.CurSlide, 0] == 111)
								{
									InItem.Lyrics[2].Text = gf.FolderLyricsHeading[InItem.FolderNo, 0];
								}
								else
								{
									if (InItem.Slide[InItem.CurSlide, 0] == 112)
									{
										InItem.Lyrics[2].Text = gf.FolderLyricsHeading[InItem.FolderNo, 0] + ((gf.FolderLyricsHeading[InItem.FolderNo, 0] != "") ? " (2)" : "");
									}
									else
									{
										if (InItem.Slide[InItem.CurSlide, 0] == 100)
										{
											InItem.Lyrics[2].Text = gf.FolderLyricsHeading[InItem.FolderNo, 2];
										}
										else
										{
											if (InItem.Slide[InItem.CurSlide, 0] == 103)
											{
												InItem.Lyrics[2].Text = gf.FolderLyricsHeading[InItem.FolderNo, 2] + ((gf.FolderLyricsHeading[InItem.FolderNo, 2] != "") ? " (2)" : "");
											}
											else
											{
												if (InItem.Slide[InItem.CurSlide, 0] == 101)
												{
													InItem.Lyrics[2].Text = gf.FolderLyricsHeading[InItem.FolderNo, 3];
												}
												else
												{
													if (InItem.Verse2Present || (InItem.CurSlide > 1 && InItem.Slide[InItem.CurSlide, 0] == 1))
													{
														InItem.Lyrics[2].Text = gf.VerseTitle[InItem.Slide[InItem.CurSlide, 0]];
													}
													else
													{
														InItem.Lyrics[2].Text = "";
													}
												}
											}
										}
									}
								}
							}
						}
					}
					else
					{
						InItem.Lyrics[2].Text = InItem.Title;
					}
				}
				else
				{
					InItem.Lyrics[2].Text = "";
				}
			}
			if (gf.ShowRunning_ShowNotations == 1)
			{
				num = ((num > 0) ? 0 : 1);
			}
			num2 = (num2 + gf.ShowRunning_ShowVerticalAlign) % 3;
			if (InItem.FirstShowing)
			{
				InPictureBox.TransitionType = (ImageTransitionControl.TransitionTypes)transitionType;
				if (gf.LicAdminEnforceDisplay)
				{
					InItem.Show_LicAdim = true;
				}
			}
			else
			{
				InPictureBox.TransitionType = (ImageTransitionControl.TransitionTypes)transitionType2;
			}
			if (InItem.FirstShowing || RedoBackground || gf.ComputeTransition(InItem, ref InPictureBox, TransitionAction) != ImageTransitionControl.TransitionTypes.None)
			{
				if (InItem.Format.MediaTransparent || (gf.ShowLiveCam && InItem.AtLiveScreen))
				{
					gf.SetTransparentBackground(InItem, ref InPictureBox);
				}
				else
				{
					gf.SetShowBackground(InItem, ref InPictureBox, !(InItem.Type == "G"));
				}
			}
			else
			{
				if (gf.ShowLiveCam && InItem.AtLiveScreen)
				{
					gf.SetTransparentBackground(InItem, ref InPictureBox);
				}
			}
			if (InItem.Type != "")
			{
				gf.DrawText(ref InItem, ref InPictureBox, InItem.LyricsAndNotationsList, inUseShadowFont, inUseOutlineFont, num, inShowInterlace, num2, inHideDisplayPanel, TransitionAction, DoActiveIndicator, false);
			}
			return true;
		}
		public static void DrawText(ref gf.SongSettings InItem, ref ImageTransitionControl PPictureBox, ref ImageTransitionControl OPictureBox, ListView LyricsAndNotationsList)
		{
			if (InItem.OutputStyleScreen)
			{
				gf.DrawText(ref InItem, ref OPictureBox, LyricsAndNotationsList, InItem.Format.UseShadowFont, InItem.Format.UseOutlineFont, InItem.Format.ShowNotations, InItem.Format.ShowInterlace, InItem.Format.ShowVerticalAlign, InItem.Format.HideDisplayPanel, (ImageTransitionControl.TransitionAction)InItem.Format.ShowSlideTransition, false, false);
			}
			else
			{
				gf.DrawText(ref InItem, ref PPictureBox, LyricsAndNotationsList, InItem.Format.UseShadowFont, InItem.Format.UseOutlineFont, InItem.Format.ShowNotations, InItem.Format.ShowInterlace, InItem.Format.ShowVerticalAlign, InItem.Format.HideDisplayPanel, (ImageTransitionControl.TransitionAction)InItem.Format.ShowSlideTransition, false, false);
			}
		}
		public static void DrawText(ref gf.SongSettings InItem, ref ImageTransitionControl InPictureBox, ListView LyricsAndNotationsList, bool DoActiveIndicator, bool ClearAll)
		{
			gf.DrawText(ref InItem, ref InPictureBox, LyricsAndNotationsList, InItem.Format.UseShadowFont, InItem.Format.UseOutlineFont, InItem.Format.ShowNotations, InItem.Format.ShowInterlace, InItem.Format.ShowVerticalAlign, InItem.Format.HideDisplayPanel, (ImageTransitionControl.TransitionAction)InItem.Format.ShowSlideTransition, DoActiveIndicator, ClearAll);
		}
		public static void DrawText(ref gf.SongSettings InItem, ref ImageTransitionControl InPictureBox, ListView LyricsAndNotationsList, int InUseShadowFont, int InUseOutlineFont, int InShowNotations, int InShowInterlace, int InShowVerticalAlign, int InHideDisplayPanel, ImageTransitionControl.TransitionAction TransitionAction, bool DoActiveIndicator, bool ClearAll)
		{
			bool flag = InShowInterlace == 1;
			bool liveCamOnShow = false;
			bool fitAllIntoOneScreen = (!gf.AutoTextOverflow || InItem.RotateStyle == 2) && InItem.Type != "B";
			if (!(InPictureBox.Width <= 0 | InPictureBox.Height <= 0))
			{
				if (InPictureBox.NewBackgroundPicture == null)
				{
					gf.SetShowBackground(InItem, ref InPictureBox);
				}
				int width = InPictureBox.NewBackgroundPicture.Width;
				int height = InPictureBox.NewBackgroundPicture.Height;
				for (int i = 0; i <= 2; i++)
				{
					InItem.Lyrics[i].FS_TopOffset = 0;
					InItem.Lyrics[i].FS_OneLyricAndNotationHeight = 0;
					InItem.Lyrics[i].FS_InterlaceGapHeight = 0;
					InItem.Lyrics[i].FS_InterlaceLinePattern = "";
				}
				Image image = new Bitmap(width, height, PixelFormat.Format32bppPArgb);
				Graphics graphics = Graphics.FromImage(image);
				graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
				graphics.Clear(Color.Transparent);
				Image image2 = new Bitmap(width, height, PixelFormat.Format32bppPArgb);
				Graphics graphics2 = Graphics.FromImage(image2);
				graphics2.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
				graphics2.Clear(Color.Transparent);
				if (InPictureBox.CurrentCombinedImage == null)
				{
					InPictureBox.CurrentBackgroundPicture = (Image)InPictureBox.BackgroundImage.Clone();
					InPictureBox.CurrentTextImage = (Image)InPictureBox.BackgroundImage.Clone();
					InPictureBox.CurrentCombinedImage = (Image)InPictureBox.BackgroundImage.Clone();
				}
				if (InPictureBox.CurrentPanelImage == null)
				{
					InPictureBox.CurrentPanelImage = (Image)InPictureBox.BackgroundImage.Clone();
				}
				if (InPictureBox.NewTextImage == null)
				{
					InPictureBox.NewTextImage = (Image)InPictureBox.BackgroundImage.Clone();
				}
				if (InPictureBox.NewPanelImage == null)
				{
					InPictureBox.NewPanelImage = (Image)InPictureBox.BackgroundImage.Clone();
				}
				gf.ComputeTransition(InItem, ref InPictureBox, TransitionAction);
				if (InPictureBox.TransitionType != ImageTransitionControl.TransitionTypes.None)
				{
					InPictureBox.CurrentTextImage = (Image)InPictureBox.NewTextImage.Clone();
					InPictureBox.CurrentPanelImage = (Image)InPictureBox.NewPanelImage.Clone();
				}
				if (gf.ShowRunning_UseShadowFont == 1)
				{
					InUseShadowFont = ((InUseShadowFont > 0) ? 0 : 1);
				}
				if (gf.ShowRunning_UseOutlineFont == 1)
				{
					InUseOutlineFont = ((InUseOutlineFont > 0) ? 0 : 1);
				}
				if (gf.ShowRunning_ShowInterlace == 1)
				{
					flag = !flag;
				}
				if (gf.ShowLiveCam & InItem.AtLiveScreen)
				{
					ClearAll = true;
					liveCamOnShow = true;
				}
				else
				{
					if (InItem.OutputStyleScreen && gf.ShowLiveClear)
					{
						ClearAll = true;
					}
				}
				if (InItem.OutputStyleScreen && gf.ShowLiveBlack)
				{
					ClearAll = true;
					graphics.Clear(gf.BlackScreenColour);
					graphics2.Clear(gf.BlackScreenColour);
				}
				if (ClearAll)
				{
					InPictureBox.NewPanelImage = image2;
				}
				else
				{
					if (InItem.Lyrics[0].Font == null)
					{
						InPictureBox.NewPanelImage = image2;
					}
					else
					{
						if ((gf.ShowDataDisplayMode == 1 && InHideDisplayPanel == 0) | InItem.Show_LicAdim)
						{
							if (InItem.Type != "G")
							{
								gf.DrawDisplayPanel(InItem, InHideDisplayPanel, ref InPictureBox, graphics2);
							}
						}
						InPictureBox.NewPanelImage = image2;
						int num = (int)InItem.Lyrics[1].FS_Font.Size;
						if (InItem.Type == "D" | InItem.Type == "B" | InItem.Type == "T" | InItem.Type == "I" | InItem.Type == "W" | InItem.Type == "M")
						{
							int num2 = (InItem.Format.ShowLyrics + gf.ShowRunning_ShowLyrics) % 3;
							int num3 = (InItem.Format.ShowSongHeadings == 1 || (InItem.Format.ShowSongHeadings == 2 && InItem.FirstShowing)) ? 1 : 0;
							num3 = (num3 + gf.ShowRunning_ShowSongHeadings) % 2;
							if (InItem.Type == "M")
							{
								num3 = 0;
							}
							InItem.CurSlideIsVerse = false;
							int num4 = InItem.CurSlide;
							if (InItem.Slide[num4, 0] < 0)
							{
								num4--;
								while (num4 >= 0 && InItem.Slide[num4, 0] < 0)
								{
									num4--;
								}
								if (num4 < 0)
								{
									num4 = 0;
								}
							}
							InItem.CurSlideIsVerse = (InItem.Slide[num4, 0] > 0 && InItem.Slide[num4, 0] < 99);
							bool flag2 = false;
							if (num2 < 2 | InItem.Slide[InItem.CurSlide, 1] < 0 | InItem.Slide[InItem.CurSlide, 3] < 0)
							{
								flag2 = true;
								flag = false;
							}
							int num5 = 0;
							int num6 = 0;
							Font font = new Font("Microsoft Sans Serif", 30f);
							Font font2 = new Font("Microsoft Sans Serif", 30f);
							Font font3 = new Font("Microsoft Sans Serif", 30f);
							Font font4 = new Font("Microsoft Sans Serif", 30f);
							Font font5 = new Font("Microsoft Sans Serif", 30f);
							int num7 = 0;
							int num8 = 0;
							int oneRegionHeight = gf.GetOneRegionHeight(ref InItem, ref InPictureBox, 2, LyricsAndNotationsList, ref graphics, InUseShadowFont, InUseOutlineFont, InShowNotations, flag2, ref font, ref font4, InShowInterlace, fitAllIntoOneScreen, gf.UseLargestFontSize);
							if (num2 == 0 | num2 == 2)
							{
								num5 = gf.GetOneRegionHeight(ref InItem, ref InPictureBox, 0, LyricsAndNotationsList, ref graphics, InUseShadowFont, InUseOutlineFont, InShowNotations, flag2, ref font2, ref font4, InShowInterlace, fitAllIntoOneScreen, gf.UseLargestFontSize);
							}
							if (num2 == 1 | num2 == 2)
							{
								num6 = gf.GetOneRegionHeight(ref InItem, ref InPictureBox, 1, LyricsAndNotationsList, ref graphics, InUseShadowFont, InUseOutlineFont, InShowNotations, flag2, ref font3, ref font5, InShowInterlace, fitAllIntoOneScreen, gf.UseLargestFontSize);
								if (flag2)
								{
									InItem.Lyrics[1].FS_Top = InItem.Lyrics[0].FS_Top;
								}
							}
							if (InShowVerticalAlign == 0)
							{
								num7 = ((num3 > 0) ? 0 : (-oneRegionHeight));
							}
							else
							{
								if (InShowVerticalAlign == 1)
								{
									num7 = (InItem.Lyrics[0].FS_Height - (num5 + num6 + num8 + ((num3 > 0) ? ((InItem.Lyrics[2].Text != "") ? 0 : oneRegionHeight) : oneRegionHeight))) / 2;
								}
								else
								{
									if (InShowVerticalAlign == 2)
									{
										num7 = InItem.Lyrics[0].FS_Height - (num5 + num6 + num8);
									}
								}
							}
							num7 += gf.ShowTopBorderSize;
							if (num2 == 0 | num2 == 2)
							{
								gf.DrawOneRegion(ref InItem, ref InPictureBox, 0, LyricsAndNotationsList, ref graphics, InUseShadowFont, InUseOutlineFont, InShowNotations, flag2, ref font2, ref font4, num7, flag, InShowVerticalAlign, 0, fitAllIntoOneScreen, gf.UseLargestFontSize);
							}
							if (num2 == 1 | num2 == 2)
							{
								gf.DrawOneRegion(ref InItem, ref InPictureBox, 1, LyricsAndNotationsList, ref graphics, InUseShadowFont, InUseOutlineFont, InShowNotations, flag2, ref font3, ref font5, num7, flag, InShowVerticalAlign, num5 + num8, fitAllIntoOneScreen, gf.UseLargestFontSize);
							}
							if (num3 > 0)
							{
								gf.DrawOneRegion(ref InItem, ref InPictureBox, 2, LyricsAndNotationsList, ref graphics, InUseShadowFont, InUseOutlineFont, InShowNotations, flag2, ref font, ref font5, num7, flag, InShowVerticalAlign, 0, fitAllIntoOneScreen, gf.UseLargestFontSize);
							}
						}
						if (InShowNotations == 1 & InItem.Capo > 0)
						{
							gf.DrawCapoSettings(InItem, graphics);
						}
					}
				}
				bool firstShowing = InItem.FirstShowing;
				if (InItem.FirstShowing)
				{
					InPictureBox.TransitionTime = ((gf.ShowRunning && InItem.OutputStyleScreen && !InItem.AtLiveScreen) ? 0.7f : 1.5f);
					InPictureBox.ItemChanged = true;
				}
				else
				{
					InPictureBox.TransitionTime = ((gf.ShowRunning && InItem.OutputStyleScreen && !InItem.AtLiveScreen) ? 0.1f : 0.6f);
					InPictureBox.ItemChanged = false;
				}
				if (!ClearAll)
				{
					InItem.FirstShowing = false;
				}
				if (InPictureBox.TransitionType != ImageTransitionControl.TransitionTypes.None)
				{
					InPictureBox.CurrentTextImage = (Image)InPictureBox.NewTextImage.Clone();
				}
				InPictureBox.NewTextImage = image;
				if (firstShowing || DoActiveIndicator)
				{
					gf.LoadReferenceAlert(ref InPictureBox, InItem, ClearAll, DoActiveIndicator);
				}
				InPictureBox.Go(TransitionAction, firstShowing, ClearAll, DoActiveIndicator, liveCamOnShow);
				GC.Collect();
			}
		}
		public static ImageTransitionControl.TransitionTypes ComputeTransition(gf.SongSettings InItem, ref ImageTransitionControl InPictureBox, ImageTransitionControl.TransitionAction TransitionAction)
		{
			bool flag = false;
			if ((gf.ShowLiveCam & InItem.AtLiveScreen) || (InItem.OutputStyleScreen && gf.ShowLiveBlack && TransitionAction != ImageTransitionControl.TransitionAction.AsFade))
			{
				flag = true;
			}
			if (InItem.PrevItemPP || flag)
			{
				InPictureBox.TransitionType = ImageTransitionControl.TransitionTypes.None;
			}
			else
			{
				if (TransitionAction != ImageTransitionControl.TransitionAction.AsStored)
				{
					if (InItem.FirstShowing)
					{
						InPictureBox.TransitionType = (ImageTransitionControl.TransitionTypes)InItem.Format.ShowItemTransition;
					}
					else
					{
						if (TransitionAction == ImageTransitionControl.TransitionAction.AsStoredItem)
						{
							InPictureBox.TransitionType = (ImageTransitionControl.TransitionTypes)InItem.Format.ShowItemTransition;
						}
						else
						{
							if (TransitionAction == ImageTransitionControl.TransitionAction.None)
							{
								InPictureBox.TransitionType = ImageTransitionControl.TransitionTypes.None;
							}
							else
							{
								InPictureBox.TransitionType = (ImageTransitionControl.TransitionTypes)InItem.Format.ShowSlideTransition;
							}
						}
					}
				}
			}
			return InPictureBox.TransitionType;
		}
		public static int GetOneRegionHeight(ref gf.SongSettings InItem, ref ImageTransitionControl InPictureBox, int RegNum, ListView LyricsAndNotationsList, ref Graphics g, int InUseShadowFont, int InUseOutlineFont, int InShowNotations, bool OnlyOneRegionShown, ref Font MainFont, ref Font NotationsFont, int InterlaceOption, bool FitAllIntoOneScreen, bool UseLargestFontSize)
		{
			int result;
			if (InItem.LyricsAndNotationsList.Items.Count == 0)
			{
				result = 0;
			}
			else
			{
				int num = (int)InItem.Lyrics[RegNum].FS_Font.Size;
				int num2 = (int)((double)num * gf.NotationFontFactor);
				string text = "";
				string str = "";
				int fS_Left = InItem.Lyrics[RegNum].FS_Left;
				int fS_Top = InItem.Lyrics[RegNum].FS_Top;
				int fS_Width = InItem.Lyrics[RegNum].FS_Width;
				int num3 = (InItem.Slide[0, 3] > 0 & !OnlyOneRegionShown) ? InItem.Lyrics[RegNum].FS_Height_R2Bound : InItem.Lyrics[RegNum].FS_Height;
				int num4 = InItem.Lyrics[RegNum].FS_Top + InItem.Lyrics[RegNum].FS_Height;
				int fS_Height_R2Bound = InItem.Lyrics[1].FS_Height_R2Bound;
				SizeF layoutArea = new SizeF((float)fS_Width, 32000f);
				int num5 = 0;
				int num6 = 0;
				double num7 = gf.MainFontSpacingFactor[InItem.FolderNo, (RegNum == 0) ? 0 : 1] + ((InShowNotations > 0) ? gf.NotationFontFactor : 0.0);
				int num8;
				int num9;
				if (RegNum == 0)
				{
					num8 = InItem.Slide[InItem.CurSlide, 1];
					num9 = InItem.Slide[InItem.CurSlide, 2];
				}
				else
				{
					if (RegNum != 1)
					{
						text = InItem.Lyrics[RegNum].Text;
						MainFont = new Font(InItem.Lyrics[RegNum].Font.Name, (float)num, InItem.CurSlideIsVerse ? InItem.Lyrics[RegNum].Font.Style : InItem.Lyrics[RegNum].ChorusFont.Style);
						if (UseLargestFontSize)
						{
							gf.ActionWordWrapSpacesAtStart(ref text);
						}
						gf.ReduceFontToFit(g, text, ref MainFont, fS_Width, num3, true);
						result = num3;
						return result;
					}
					num8 = InItem.Slide[InItem.CurSlide, 3];
					num9 = InItem.Slide[InItem.CurSlide, 4];
				}
				if (num8 < 0 | num9 < 0)
				{
					result = 0;
				}
				else
				{
					if (num8 <= num9)
					{
						string text2 = "";
						for (int i = num8; i <= num9; i++)
						{
							str = InItem.LyricsAndNotationsList.Items[i].SubItems[2].Text;
							if (UseLargestFontSize)
							{
								gf.ActionWordWrapSpacesAtStart(ref str);
							}
							text = text + str + "\n";
							text2 = InItem.LyricsAndNotationsList.Items[i].SubItems[4].Text;
							num5 += gf.StringToInt(gf.ExtractOneInfo(ref text2, '>', false));
							num6++;
						}
						if (text.Length > 1)
						{
							text = gf.Left(text, text.Length - 1);
						}
					}
					num3 = (int)((double)num3 / num7);
					if (UseLargestFontSize)
					{
						MainFont = new Font(InItem.Lyrics[RegNum].Font.Name, (float)num, InItem.CurSlideIsVerse ? InItem.Lyrics[RegNum].Font.Style : InItem.Lyrics[RegNum].ChorusFont.Style);
						bool flag = false;
						int num10 = gf.IncreaseFontToLargest(g, text, ref MainFont, fS_Width, num3, ref flag);
						NotationsFont = new Font(InItem.Lyrics[RegNum].Font.Name, (float)((MainFont.Size >= 2f) ? Convert.ToInt32((double)MainFont.Size * gf.NotationFontFactor) : 1), InItem.Lyrics[RegNum].Font.Style);
						InItem.Lyrics[RegNum].FS_OneLyricAndNotationHeight = (int)((double)g.MeasureString("A", MainFont, layoutArea).Height * num7);
						result = (int)((double)num10 * num7);
					}
					else
					{
						if (num5 > 0)
						{
							string text3 = InItem.LyricsAndNotationsList.Items[num8].SubItems[4].Text;
							gf.ExtractOneInfo(ref text3, '>');
							num = Convert.ToInt32(gf.ExtractOneInfo(ref text3, '>'));
							if (num < 1)
							{
								num = (int)InItem.Lyrics[RegNum].Font.Size;
							}
							MainFont = new Font(InItem.Lyrics[RegNum].Font.Name, (float)num, InItem.CurSlideIsVerse ? InItem.Lyrics[RegNum].Font.Style : InItem.Lyrics[RegNum].ChorusFont.Style);
							NotationsFont = new Font(InItem.Lyrics[RegNum].Font.Name, (float)((MainFont.Size >= 2f) ? Convert.ToInt32((double)MainFont.Size * gf.NotationFontFactor) : 1), InItem.Lyrics[RegNum].Font.Style);
							InItem.Lyrics[RegNum].FS_OneLyricAndNotationHeight = (int)((double)g.MeasureString("A", MainFont, layoutArea).Height * num7);
							result = InItem.Lyrics[RegNum].FS_OneLyricAndNotationHeight * num5;
						}
						else
						{
							MainFont = new Font(InItem.Lyrics[RegNum].Font.Name, (float)num, InItem.CurSlideIsVerse ? InItem.Lyrics[RegNum].Font.Style : InItem.Lyrics[RegNum].ChorusFont.Style);
							gf.ReduceFontToFit(g, text, ref MainFont, fS_Width, num3, true);
							int num10 = num3;
							NotationsFont = new Font(InItem.Lyrics[RegNum].Font.Name, (float)((MainFont.Size >= 2f) ? Convert.ToInt32((double)MainFont.Size * gf.NotationFontFactor) : 1), InItem.Lyrics[RegNum].Font.Style);
							InItem.Lyrics[RegNum].FS_OneLyricAndNotationHeight = (int)((double)g.MeasureString("A", MainFont, layoutArea).Height * num7);
							result = (int)((double)num10 * num7);
						}
					}
				}
			}
			return result;
		}
		public static int DrawOneRegion(ref gf.SongSettings InItem, ref ImageTransitionControl InPictureBox, int RegNum, ListView LyricsAndNotationsList, ref Graphics g, int InUseShadowFont, int InUseOutlineFont, int InShowNotations, bool OnlyOneRegionShown, ref Font MainFont, ref Font NotationsFont, int OffsetAfterAlignment, bool InterlaceOption, int InShowVerticalAlign, int Region1Height, bool FitAllIntoOneScreen, bool UseLargestFontSize)
		{
			int result;
			if (InItem.LyricsAndNotationsList.Items.Count == 0)
			{
				result = 0;
			}
			else
			{
				int num = 0;
				int num2 = -1;
				int num3 = -1;
				string lyricsText = "";
				int fS_Left = InItem.Lyrics[RegNum].FS_Left;
				int num4 = InItem.Lyrics[RegNum].FS_Top;
				int fS_Width = InItem.Lyrics[RegNum].FS_Width;
				int num5 = (InItem.Slide[0, 3] > 0 & !OnlyOneRegionShown) ? InItem.Lyrics[RegNum].FS_Height_R2Bound : InItem.Lyrics[RegNum].FS_Height;
				SizeF layoutArea = new SizeF((float)fS_Width, 32000f);
				int num6 = (int)((double)g.MeasureString("A", MainFont, layoutArea).Height * gf.MainFontSpacingFactor[InItem.FolderNo, (RegNum == 0) ? 0 : 1]);
				int notationsLineHeight = (int)((double)num6 * ((MainFont.Size >= 2f) ? gf.NotationFontFactor : 1.0));
				int notationsLineTextVOffset = 0;
				string interlaceLinePattern = (RegNum == 1) ? InItem.Lyrics[RegNum].FS_InterlaceLinePattern : "";
				int value = 0;
				if (RegNum == 0)
				{
					num2 = InItem.Slide[InItem.CurSlide, 1];
					num3 = InItem.Slide[InItem.CurSlide, 2];
				}
				else
				{
					if (RegNum == 1)
					{
						num2 = InItem.Slide[InItem.CurSlide, 3];
						num3 = InItem.Slide[InItem.CurSlide, 4];
					}
					else
					{
						if (RegNum == 2)
						{
							lyricsText = InItem.Lyrics[RegNum].Text;
							num4 += OffsetAfterAlignment;
							RectangleF rect_normal = new RectangleF((float)fS_Left, (float)(num4 + InItem.Lyrics[RegNum].FS_TopOffset), (float)fS_Width, (float)num5);
							gf.DrawOneLine(ref InItem, ref InPictureBox, InItem.Lyrics[2], 2, InItem.Slide, LyricsAndNotationsList, ref g, MainFont, NotationsFont, num6, 0, 0, rect_normal, num5, lyricsText, InUseShadowFont, InUseOutlineFont, 0);
							result = 0;
							return result;
						}
					}
				}
				if (num2 < 0 | num3 < 0)
				{
					result = 0;
				}
				else
				{
					if (OnlyOneRegionShown)
					{
						num4 += OffsetAfterAlignment;
					}
					else
					{
						if (RegNum == 0)
						{
							num4 += OffsetAfterAlignment;
							if (InterlaceOption)
							{
								InItem.Lyrics[0].FS_InterlaceGapHeight = InItem.Lyrics[1].FS_OneLyricAndNotationHeight;
							}
						}
						else
						{
							if (RegNum == 1)
							{
								if (InterlaceOption)
								{
									num4 = InItem.Lyrics[0].FS_Top + OffsetAfterAlignment + (int)((double)InItem.Lyrics[0].FS_OneLyricAndNotationHeight * 0.9);
									InItem.Lyrics[1].FS_InterlaceGapHeight = InItem.Lyrics[0].FS_OneLyricAndNotationHeight;
								}
								else
								{
									num4 = InItem.Lyrics[0].FS_Top + OffsetAfterAlignment + Region1Height + gf.Buffer_LS_Height / 30;
									if (gf.LineBetweenRegions)
									{
										gf.OutputOneLineToScreen(InItem, "<<DrawLine>>", MainFont, g, InItem.Lyrics[RegNum].ForeColour, StringAlignment.Center, InUseShadowFont, InUseOutlineFont, fS_Left, num4 - gf.Buffer_LS_Height / 40, fS_Width, 0);
									}
								}
							}
						}
					}
					InItem.Lyrics[RegNum].FS_TopOffset = num4;
					RectangleF rect_normal2 = new RectangleF((float)fS_Left, (float)num4, (float)fS_Width, (float)num5);
					RectangleF rectangleF = new RectangleF(rect_normal2.Left + MainFont.Size / 30f + 1f, rect_normal2.Top + MainFont.Size / 30f + 1f, rect_normal2.Width, rect_normal2.Height);
					if (num2 <= num3)
					{
						for (int i = num2; i <= num3; i++)
						{
							value = 0;
							gf.DrawOneLine(ref InItem, ref InPictureBox, InItem.Lyrics[RegNum], RegNum, InItem.Slide, LyricsAndNotationsList, ref g, MainFont, NotationsFont, num6, notationsLineHeight, notationsLineTextVOffset, rect_normal2, num5, lyricsText, InUseShadowFont, InUseOutlineFont, InShowNotations, i, ref num, ref value, InterlaceOption, interlaceLinePattern);
							if (RegNum == 0)
							{
								gf.SongSettings.SongLyrics expr_43D = InItem.Lyrics[1];
								expr_43D.FS_InterlaceLinePattern = expr_43D.FS_InterlaceLinePattern + Convert.ToString(value) + '>';
							}
						}
					}
					result = (int)MainFont.Size;
				}
			}
			return result;
		}
		public static void DrawOneLine(ref gf.SongSettings InItem, ref ImageTransitionControl InPictureBox, gf.SongSettings.SongLyrics InLyrics, int RegionNumber, int[,] Slide, ListView LyricsAndNotationsList, ref Graphics g, Font MainFont, Font NotationsFont, int OneLineHeight, int NotationsLineHeight, int NotationsLineTextVOffset, RectangleF rect_normal, int InHeight, string LyricsText, int InUseShadowFont, int InUseOutlineFont, int InShowNotations)
		{
			gf.DrawOneLine(ref InItem, ref InPictureBox, InLyrics, RegionNumber, Slide, LyricsAndNotationsList, ref g, MainFont, NotationsFont, OneLineHeight, NotationsLineHeight, NotationsLineTextVOffset, rect_normal, InHeight, LyricsText, InUseShadowFont, InUseOutlineFont, InShowNotations, -1);
		}
		public static void DrawOneLine(ref gf.SongSettings InItem, ref ImageTransitionControl InPictureBox, gf.SongSettings.SongLyrics InLyrics, int RegionNumber, int[,] Slide, ListView LyricsAndNotationsList, ref Graphics g, Font MainFont, Font NotationsFont, int OneLineHeight, int NotationsLineHeight, int NotationsLineTextVOffset, RectangleF rect_normal, int InHeight, string LyricsText, int InUseShadowFont, int InUseOutlineFont, int InShowNotations, int CurLine)
		{
			int num = 0;
			int num2 = 0;
			gf.DrawOneLine(ref InItem, ref InPictureBox, InLyrics, RegionNumber, Slide, LyricsAndNotationsList, ref g, MainFont, NotationsFont, OneLineHeight, NotationsLineHeight, NotationsLineTextVOffset, rect_normal, InHeight, LyricsText, InUseShadowFont, InUseOutlineFont, InShowNotations, CurLine, ref num, ref num2, false);
		}
		public static void DrawOneLine(ref gf.SongSettings InItem, ref ImageTransitionControl InPictureBox, gf.SongSettings.SongLyrics InLyrics, int RegionNumber, int[,] Slide, ListView LyricsAndNotationsList, ref Graphics g, Font MainFont, Font NotationsFont, int OneLineHeight, int NotationsLineHeight, int NotationsLineTextVOffset, RectangleF rect_normal, int InHeight, string LyricsText, int InUseShadowFont, int InUseOutlineFont, int InShowNotations, int CurLine, ref int HeightOffset)
		{
			int num = 0;
			gf.DrawOneLine(ref InItem, ref InPictureBox, InLyrics, RegionNumber, Slide, LyricsAndNotationsList, ref g, MainFont, NotationsFont, OneLineHeight, NotationsLineHeight, NotationsLineTextVOffset, rect_normal, InHeight, LyricsText, InUseShadowFont, InUseOutlineFont, InShowNotations, CurLine, ref HeightOffset, ref num, false);
		}
		public static void DrawOneLine(ref gf.SongSettings InItem, ref ImageTransitionControl InPictureBox, gf.SongSettings.SongLyrics InLyrics, int RegionNumber, int[,] Slide, ListView LyricsAndNotationsList, ref Graphics g, Font MainFont, Font NotationsFont, int OneLineHeight, int NotationsLineHeight, int NotationsLineTextVOffset, RectangleF rect_normal, int InHeight, string LyricsText, int InUseShadowFont, int InUseOutlineFont, int InShowNotations, int CurLine, ref int HeightOffset, ref int LinesRequired)
		{
			gf.DrawOneLine(ref InItem, ref InPictureBox, InLyrics, RegionNumber, Slide, LyricsAndNotationsList, ref g, MainFont, NotationsFont, OneLineHeight, NotationsLineHeight, NotationsLineTextVOffset, rect_normal, InHeight, LyricsText, InUseShadowFont, InUseOutlineFont, InShowNotations, CurLine, ref HeightOffset, ref LinesRequired, false);
		}
		public static void DrawOneLine(ref gf.SongSettings InItem, ref ImageTransitionControl InPictureBox, gf.SongSettings.SongLyrics InLyrics, int RegionNumber, int[,] Slide, ListView LyricsAndNotationsList, ref Graphics g, Font MainFont, Font NotationsFont, int OneLineHeight, int NotationsLineHeight, int NotationsLineTextVOffset, RectangleF rect_normal, int InHeight, string LyricsText, int InUseShadowFont, int InUseOutlineFont, int InShowNotations, int CurLine, ref int HeightOffset, ref int LinesRequired, bool InterlaceOption)
		{
			gf.DrawOneLine(ref InItem, ref InPictureBox, InLyrics, RegionNumber, Slide, LyricsAndNotationsList, ref g, MainFont, NotationsFont, OneLineHeight, NotationsLineHeight, NotationsLineTextVOffset, rect_normal, InHeight, LyricsText, InUseShadowFont, InUseOutlineFont, InShowNotations, CurLine, ref HeightOffset, ref LinesRequired, InterlaceOption, "");
		}
		public static void DrawOneLine(ref gf.SongSettings InItem, ref ImageTransitionControl InPictureBox, gf.SongSettings.SongLyrics InLyrics, int RegionNumber, int[,] Slide, ListView LyricsAndNotationsList, ref Graphics g, Font MainFont, Font NotationsFont, int OneLineHeight, int NotationsLineHeight, int NotationsLineTextVOffset, RectangleF rect_normal, int InHeight, string LyricsText, int InUseShadowFont, int InUseOutlineFont, int InShowNotations, int CurLine, ref int HeightOffset, ref int LinesRequired, bool InterlaceOption, string InterlaceLinePattern)
		{
			StringFormat stringFormat = new StringFormat();
			SizeF sizeF = new SizeF(rect_normal.Width, 32000f);
			int startPos = 0;
			int num = -1;
			int num2 = Convert.ToInt32(gf.ExtractOneInfo(ref InterlaceLinePattern, '>'));
			if (num2 < 0)
			{
				num2 = 0;
			}
			string notationsString;
			string text;
			if (CurLine < 0)
			{
				if (LyricsText == "")
				{
					return;
				}
				notationsString = "";
				text = "";
			}
			else
			{
				LyricsText = InItem.LyricsAndNotationsList.Items[CurLine].SubItems[2].Text;
				notationsString = InItem.LyricsAndNotationsList.Items[CurLine].SubItems[3].Text;
				text = InItem.LyricsAndNotationsList.Items[CurLine].SubItems[4].Text;
			}
			if (InterlaceOption & RegionNumber == 1)
			{
				while (g.MeasureString(LyricsText, MainFont, 100000).Width + 10f > rect_normal.Width * (float)num2 & MainFont.Size > 1f)
				{
					MainFont = new Font(InLyrics.Font.Name, MainFont.Size - 1f, InLyrics.Font.Style);
					NotationsFont = new Font(InLyrics.Font.Name, (float)Convert.ToInt32((double)MainFont.Size * gf.NotationFontFactor), InLyrics.Font.Style);
				}
			}
			LinesRequired++;
			string text2 = "";
			if (gf.UseLargestFontSize)
			{
				text = "";
				text2 = gf.ActionWordWrapSpacesAtStart(ref LyricsText);
			}
			int num3 = Convert.ToInt32(gf.ExtractOneInfo(ref text, '>'));
			if (num3 > 0)
			{
				if (num3 == 1)
				{
					num3 = 0;
				}
				else
				{
					gf.ExtractOneInfo(ref text, '>');
					num3 = Convert.ToInt32(gf.ExtractOneInfo(ref text, '>'));
				}
			}
			string a = gf.DisplayTextByWidthOneLine(InItem, LyricsText, InLyrics, RegionNumber, MainFont, NotationsFont, g, (int)rect_normal.Left, (int)rect_normal.Top, (int)rect_normal.Width, ref HeightOffset, OneLineHeight, NotationsLineHeight, NotationsLineTextVOffset, startPos, InUseShadowFont, InUseOutlineFont, InShowNotations, notationsString, ref num, ref num2, InterlaceOption, num3, false, ref text2);
			if (num3 > 0)
			{
				num3 = Convert.ToInt32(gf.ExtractOneInfo(ref text, '>'));
			}
			while (a != "" & num > 0)
			{
				startPos = num + 1;
				LinesRequired++;
				a = gf.DisplayTextByWidthOneLine(InItem, LyricsText, InLyrics, RegionNumber, MainFont, NotationsFont, g, (int)rect_normal.Left, (int)rect_normal.Top, (int)rect_normal.Width, ref HeightOffset, OneLineHeight, NotationsLineHeight, NotationsLineTextVOffset, startPos, InUseShadowFont, InUseOutlineFont, InShowNotations, notationsString, ref num, ref num2, InterlaceOption, num3, true, ref text2);
				if (num3 > 0)
				{
					num3 = Convert.ToInt32(gf.ExtractOneInfo(ref text, '>'));
				}
			}
			if (num2 > 0 & InterlaceOption)
			{
				HeightOffset += (InLyrics.FS_OneLyricAndNotationHeight + InLyrics.FS_InterlaceGapHeight) * num2;
			}
		}
		public static string DisplayTextByWidthOneLine(gf.SongSettings InItem, string InText, gf.SongSettings.SongLyrics InLyrics, int RegionNumber, Font MainFont, Font NotationsFont, Graphics g, int InLeft, int InTop, int InWidth, ref int HeightOffset, int OneLineHeight, int NotationsLineHeight, int NotationsLineTextVOffset, int StartPos, int InUseShadowFont, int InUseOutlineFont, int InShowNotations, string NotationsString, ref int EndExtractedTextPos, ref int R2_MaxLinesPermitted, bool InterlaceOption, int InSetLength, bool IsWrappedText, ref string ReplacedLog)
		{
			int length = InText.Length;
			string result;
			if (length == 0)
			{
				EndExtractedTextPos = -1;
				result = "";
			}
			else
			{
				string text = "";
				R2_MaxLinesPermitted--;
				gf.SubDivideOneOutputText(InText, MainFont, NotationsFont, g, InWidth, InShowNotations, NotationsString, length, InSetLength, StartPos, ref EndExtractedTextPos, ref text);
				int num = (int)((double)g.MeasureString(text, MainFont).Width);
				HeightOffset += ((InShowNotations == 1) ? NotationsLineHeight : 0);
				gf.ActionUndoWordWrapSpacesAtStart(ref text, ref ReplacedLog);
				gf.SubstituteDashes(ref text, InShowNotations);
				int num2 = gf.OutputOneLineToScreen(InItem, text, MainFont, g, InLyrics.ForeColour, InLyrics.TextAlign, InUseShadowFont, InUseOutlineFont, InLeft, InTop + HeightOffset, InWidth, 0, IsWrappedText && gf.WordWrapLeftAlignIndent && InItem.Type != "I" && RegionNumber != 2);
				if (InShowNotations == 1)
				{
					int num3 = (int)MainFont.Size - 2;
					if (num3 < 1)
					{
						num3 = 1;
					}
					Font font = new Font(MainFont.Name, (float)num3);
					HeightOffset -= NotationsLineHeight;
					int num4 = 0;
					while (NotationsString != "")
					{
						string text2 = gf.ExtractOneInfo(ref NotationsString, ';');
						int num5 = Convert.ToInt32(gf.ExtractOneInfo(ref NotationsString, ';'));
						if (text2 != "-1" & num5 >= 0)
						{
							if (num5 >= StartPos)
							{
								for (int i = StartPos; i <= EndExtractedTextPos; i++)
								{
									if (i == num5 & ((i == EndExtractedTextPos) ? ((EndExtractedTextPos == length) ? true : false) : true))
									{
										int iLen = i - StartPos;
										string text3 = gf.Mid(InText, StartPos, iLen);
										int num6 = (int)g.MeasureString(text3, font).Width;
										gf.OutputOneLineToScreen(InItem, text2, NotationsFont, g, InLyrics.ForeColour, StringAlignment.Near, InUseShadowFont, InUseOutlineFont, num2 + num6 + num4, InTop + HeightOffset + NotationsLineTextVOffset, InWidth, 0, IsWrappedText && gf.WordWrapLeftAlignIndent && InItem.Type != "I");
										num4 += (int)((i == EndExtractedTextPos) ? g.MeasureString(text2 + "S", NotationsFont).Width : 0f);
										i = EndExtractedTextPos;
									}
								}
							}
						}
					}
					HeightOffset += NotationsLineHeight;
				}
				HeightOffset += (InterlaceOption ? (InLyrics.FS_OneLyricAndNotationHeight + InLyrics.FS_InterlaceGapHeight) : OneLineHeight);
				result = gf.Right(InText, length - EndExtractedTextPos - 1);
			}
			return result;
		}
		public static void SubstituteDashes(ref string ExtractedText, int InShowNotations)
		{
			if (InShowNotations < 1)
			{
				ExtractedText = ExtractedText.Replace(gf.DashesString, gf.DashesStringSubstitute);
				ExtractedText = ExtractedText.Replace(gf.DashesStringSubstitute + "---", "");
				ExtractedText = ExtractedText.Replace(gf.DashesStringSubstitute + "--", "");
				ExtractedText = ExtractedText.Replace(gf.DashesStringSubstitute + "-", "");
				ExtractedText = ExtractedText.Replace(gf.DashesStringSubstitute, "");
			}
		}
		public static void SubDivideOneOutputText(string InText, Font MainFont, Font NotationsFont, Graphics g, int InWidth, int InShowNotations, string NotationsString, int TextLength, int InSetLength, int StartPos, ref int EndExtractedTextPos, ref string ExtractedText)
		{
			int num = -1;
			bool flag = false;
			int num2 = 0;
			if (InSetLength == 0)
			{
				ExtractedText = InText;
				EndExtractedTextPos = TextLength;
			}
			else
			{
				if (InSetLength > 0)
				{
					for (int i = StartPos; i <= StartPos + InSetLength - 1; i++)
					{
						if (gf.Mid(InText, i, 1) == " ")
						{
							StartPos++;
							InSetLength--;
						}
						else
						{
							i = StartPos + InSetLength;
						}
					}
					ExtractedText = gf.Mid(InText, StartPos, InSetLength);
					EndExtractedTextPos = StartPos + InSetLength - 1;
				}
				else
				{
					for (int i = StartPos; i <= TextLength; i++)
					{
						if (gf.Mid(InText, i, 1) == " ")
						{
							num = i;
							flag = true;
							if (i == TextLength)
							{
								ExtractedText = gf.Mid(InText, StartPos, TextLength - StartPos + 1);
								EndExtractedTextPos = TextLength;
							}
						}
						else
						{
							if (g.MeasureString(gf.Mid(InText, StartPos, i - StartPos + 1), MainFont).Width > (float)InWidth)
							{
								if (flag)
								{
									ExtractedText = gf.Mid(InText, StartPos, num - StartPos);
									num2 = num + 1;
									EndExtractedTextPos = num2 - 1;
									i = TextLength;
								}
								else
								{
									ExtractedText = gf.Mid(InText, StartPos, i - StartPos);
									num2 = i;
									EndExtractedTextPos = num2 - 1;
									i = TextLength;
								}
							}
							else
							{
								if (i == TextLength)
								{
									ExtractedText = gf.Mid(InText, StartPos, TextLength - StartPos + 1);
									EndExtractedTextPos = TextLength;
								}
							}
						}
					}
					if (num2 > 0)
					{
						for (int j = EndExtractedTextPos + 1; j <= TextLength; j++)
						{
							if (gf.Mid(InText, j, 1) == " ")
							{
								EndExtractedTextPos++;
							}
							else
							{
								j = TextLength + 1;
							}
						}
					}
				}
			}
		}
		public static int OutputOneLineToScreen(gf.SongSettings InItem, string ExtractedText, Font InFont, Graphics g, Color InColour, StringAlignment alignformat, int InUseShadowFont, int InUseOutlineFont, int x, int y, int w, int h)
		{
			return gf.OutputOneLineToScreen(InItem, ExtractedText, InFont, g, InColour, alignformat, InUseShadowFont, InUseOutlineFont, x, y, w, h, false);
		}
		public static int OutputOneLineToScreen(gf.SongSettings InItem, string ExtractedText, Font InFont, Graphics g, Color InColour, StringAlignment alignformat, int InUseShadowFont, int InUseOutlineFont, int x, int y, int w, int h, bool IndentLeftAligned)
		{
			GraphicsPath graphicsPath = new GraphicsPath();
			GraphicsPath graphicsPath2 = new GraphicsPath();
			float num = InFont.Size / (float)gf.AdjustedOutlineThreshold;
			string text = "";
			if (InItem.Type == "B")
			{
				if (ExtractedText.IndexOf('\u0098') >= 0)
				{
					string[] array = ExtractedText.Split(new char[]
					{
						'\u0098'
					});
					if (array.GetUpperBound(0) > 0)
					{
						text = gf.Trim(array[0]);
						ExtractedText = gf.Trim(array[1]);
					}
				}
			}
			if (num < 1f)
			{
				num = 1f;
			}
			Pen pen = new Pen(gf.BlackScreenColour, num);
			int num2 = (int)((double)InFont.Size * 1.2999999523162842);
			int x2 = x;
			StringFormat stringFormat = new StringFormat();
			if (alignformat == StringAlignment.Center)
			{
				x += w / 2;
			}
			else
			{
				if (alignformat == StringAlignment.Far)
				{
					x += w;
				}
				else
				{
					if (IndentLeftAligned)
					{
						ExtractedText = "  " + ExtractedText;
					}
				}
			}
			int result;
			if (InFont.Size <= 1f)
			{
				result = x;
			}
			else
			{
				stringFormat.Alignment = alignformat;
				g.SmoothingMode = SmoothingMode.AntiAlias;
				int num3 = 0;
				int num4 = num2 / 10;
				if (num4 < 1)
				{
					num4 = 1;
				}
				int num5 = y;
				if (h > 0)
				{
					graphicsPath2.AddString(ExtractedText, new FontFamily(InFont.Name), (int)InFont.Style, (float)num2, new Rectangle(num3 + x, y, w, h), stringFormat);
					int num6 = (int)graphicsPath2.GetBounds().Height + 10;
					num5 += h - num6;
				}
				int num8;
				if (InUseShadowFont > 0)
				{
					int num7 = (int)(InFont.Size / 22f) + 1;
					if (text != "" && alignformat == StringAlignment.Near)
					{
						num3 = gf.DrawSuperScript(graphicsPath, text, InFont, num2, new Rectangle(x + num7, y + num7, (h == 0) ? 0 : w, h), true);
						g.FillPath(new SolidBrush(gf.BlackScreenColour), graphicsPath);
						graphicsPath.Reset();
					}
					if (ExtractedText == "<<DrawLine>>")
					{
						graphicsPath.AddRectangle(new Rectangle(x2, y, w, num4));
					}
					else
					{
						if (h == 0)
						{
							graphicsPath.AddString(ExtractedText, new FontFamily(InFont.Name), (int)InFont.Style, (float)num2, new Point(num3 + x + num7, y + num7), stringFormat);
						}
						else
						{
							graphicsPath.AddString(ExtractedText, new FontFamily(InFont.Name), (int)InFont.Style, (float)num2, new Rectangle(num3 + x + num7, num5 + num7, w, h), stringFormat);
						}
					}
					g.FillPath(new SolidBrush(gf.BlackScreenColour), graphicsPath);
					num8 = (int)graphicsPath.GetBounds().Left;
					graphicsPath.Reset();
					if (text != "" && alignformat != StringAlignment.Near)
					{
						gf.DrawSuperScript(graphicsPath, text, InFont, num2, new Rectangle(num8, y + num7, (h == 0) ? 0 : w, h), false);
						g.FillPath(new SolidBrush(gf.BlackScreenColour), graphicsPath);
						graphicsPath.Reset();
					}
				}
				if (text != "" && alignformat == StringAlignment.Near)
				{
					num3 = gf.DrawSuperScript(graphicsPath, text, InFont, num2, new Rectangle(x, y, (h == 0) ? 0 : w, h), true);
					g.FillPath(new SolidBrush(InColour), graphicsPath);
					if (InUseOutlineFont > 0)
					{
						g.DrawPath(pen, graphicsPath);
					}
					graphicsPath.Reset();
				}
				if (ExtractedText == "<<DrawLine>>")
				{
					graphicsPath.AddRectangle(new Rectangle(x2, y, w, num4));
				}
				else
				{
					if (h == 0)
					{
						graphicsPath.AddString(ExtractedText, new FontFamily(InFont.Name), (int)InFont.Style, (float)num2, new Point(num3 + x, y), stringFormat);
					}
					else
					{
						graphicsPath.AddString(ExtractedText, new FontFamily(InFont.Name), (int)InFont.Style, (float)num2, new Rectangle(num3 + x, num5, w, h), stringFormat);
					}
				}
				g.FillPath(new SolidBrush(InColour), graphicsPath);
				if (InUseOutlineFont > 0)
				{
					g.DrawPath(pen, graphicsPath);
				}
				num8 = (int)graphicsPath.GetBounds().Left;
				graphicsPath.Reset();
				if (text != "" && alignformat != StringAlignment.Near)
				{
					gf.DrawSuperScript(graphicsPath, text, InFont, num2, new Rectangle(num8, y, (h == 0) ? 0 : w, h), false);
					g.FillPath(new SolidBrush(InColour), graphicsPath);
					if (InUseOutlineFont > 0)
					{
						g.DrawPath(pen, graphicsPath);
					}
					graphicsPath.Reset();
				}
				if (InUseOutlineFont > 0)
				{
					g.DrawPath(pen, graphicsPath);
				}
				if (h == 0)
				{
					result = num8;
				}
				else
				{
					result = num5;
				}
			}
			return result;
		}
		public static int DrawSuperScript(GraphicsPath pth, string InText, Font InFont, int InFontSize, Rectangle InRectangle, bool AlignLeft)
		{
			StringFormat stringFormat = new StringFormat();
			if (AlignLeft)
			{
				stringFormat.Alignment = StringAlignment.Near;
			}
			else
			{
				stringFormat.Alignment = StringAlignment.Far;
			}
			InFontSize = InFontSize * 7 / 10;
			if (InRectangle.Height == 0)
			{
				pth.AddString(InText, new FontFamily(InFont.Name), (int)InFont.Style, (float)InFontSize, new Point(InRectangle.Left, InRectangle.Top), stringFormat);
			}
			else
			{
				pth.AddString(InText, new FontFamily(InFont.Name), (int)InFont.Style, (float)InFontSize, InRectangle, stringFormat);
			}
			int num = (int)pth.GetBounds().Width;
			int num2 = num / InText.Length * 2 / 3;
			return num + num2;
		}
		public static void ReverseString(ref string InString)
		{
			if (InString.Length != 0)
			{
				string text = "";
				for (int i = InString.Length - 1; i >= 0; i--)
				{
					text += InString[i].ToString();
				}
				InString = text;
			}
		}
		public static void DrawCapoSettings(gf.SongSettings InItem, Graphics g)
		{
			gf.SongSettings.SongLyrics songLyrics = InItem.Lyrics[3];
			StringFormat stringFormat = new StringFormat();
			int value = (int)songLyrics.FS_Font.Size;
			int fS_Left = songLyrics.FS_Left;
			int fS_Top = songLyrics.FS_Top;
			int fS_Width = songLyrics.FS_Width;
			int fS_Height = songLyrics.FS_Height;
			stringFormat.Alignment = StringAlignment.Far;
			Font font = new Font(songLyrics.FS_Font.Name, (float)Convert.ToInt32(value), songLyrics.FS_Font.Style);
			int num = fS_Top + fS_Height / 2;
			RectangleF layoutRectangle = new RectangleF((float)fS_Left, (float)num, (float)fS_Width, (float)fS_Height);
			g.DrawString("Capo " + Convert.ToString(InItem.Capo), font, new SolidBrush(songLyrics.ForeColour), layoutRectangle, stringFormat);
		}
		public static void DrawDisplayPanel(gf.SongSettings InItem, int InHideDisplayPanel, ref ImageTransitionControl InPictureBox, Graphics g)
		{
			if (!(InItem.ItemID == ""))
			{
				gf.SongSettings.SongLyrics songLyrics = InItem.Lyrics[3];
				StringFormat stringFormat = new StringFormat();
				int num = (int)songLyrics.FS_Font.Size;
				int num2 = 0;
				Color inColour = (gf.PanelTextColourAsRegion1 > 0) ? songLyrics.ForeColour : gf.PanelTextColour;
				int fS_Left = songLyrics.FS_Left;
				int fS_Top = songLyrics.FS_Top;
				int fS_Width = songLyrics.FS_Width;
				int fS_Height = songLyrics.FS_Height;
				if (gf.PanelBackColourTransparent < 1)
				{
					g.FillRectangle(new SolidBrush(gf.PanelBackColour), 0, fS_Top - 5, gf.Buffer_LS_Width, fS_Height + 5);
				}
				Font font = new Font(songLyrics.FS_Font.Name, (float)num, songLyrics.FS_Font.Style);
				string text = InItem.Writer + ((InItem.Writer != "" & InItem.Copyright != "") ? "; " : "") + InItem.Copyright;
				string text2 = text;
				text = string.Concat(new string[]
				{
					text2,
					(text == "") ? "" : " ",
					InItem.Show_LicAdminInfo1,
					(InItem.Show_LicAdminInfo1 == "") ? "" : " ",
					InItem.Show_LicAdminInfo2
				});
				string text3 = InItem.PrevTitle;
				string text4 = InItem.NextTitle;
				if (gf.ShowDataDisplayMode > 0 && InHideDisplayPanel == 0)
				{
					int num3 = 0;
					float num4 = 1.18f;
					int num5 = (int)((float)fS_Width * 0.15f);
					int num6 = (int)((float)fS_Width * ((InItem.TotalSlides > 20) ? 0.15f : 0.25f));
					int num7 = (int)((float)fS_Width * (0.34f + (float)(gf.ShowDataDisplayIndicatorsFontSize - 8) * 0.032f));
					int num8 = fS_Width;
					int num9 = gf.DisplayFontSize(11, gf.Buffer_LS_Width, 3, 1);
					font = new Font(songLyrics.FS_Font.Name, (float)num9, songLyrics.FS_Font.Style);
					int num10 = num9 * fS_Height / num;
					int num11 = fS_Top + (fS_Height - num10);
					if (gf.ShowDataDisplayPrevNext > 0)
					{
						num8 -= num5;
						string text5 = "<<";
						string text6 = ">>";
						if (text3 == "")
						{
							text5 = "...  ";
						}
						if (text4 == "")
						{
							text6 = "...  ";
						}
						int num12 = (int)(g.MeasureString(text5, font, 10000).Width * num4);
						int num13 = (int)(g.MeasureString(text6, font, 10000).Width * num4);
						int num14 = (int)(g.MeasureString(text3, font, 10000).Width * num4);
						int num15 = (int)(g.MeasureString(text4, font, 10000).Width * num4);
						if (num6 > 0)
						{
							if (num14 > 0 && num14 > num6 - num12)
							{
								float num16 = (float)(num6 - num12) / (float)num14;
								text3 = gf.Left(text3, (int)(num16 * (float)(text3.Length - 3))) + "...";
							}
							if (num15 > 0 && num15 > num6 - num13)
							{
								float num16 = (float)(num6 - num13) / (float)num15;
								text4 = gf.Left(text4, (int)(num16 * (float)(text4.Length - 3))) + "...";
							}
						}
						text3 += text5;
						text4 += text6;
						num14 = (int)(g.MeasureString(text3, font, 10000).Width * num4);
						num15 = (int)(g.MeasureString(text4, font, 10000).Width * num4);
						int arg_431_0 = (num14 > num15) ? num14 : num15;
						stringFormat.Alignment = StringAlignment.Far;
						RectangleF rectangleF = new RectangleF((float)(fS_Width - num14), (float)(num11 + 1), (float)num14, (float)num10);
						gf.OutputOneLineToScreen(InItem, text3, font, g, inColour, stringFormat.Alignment, gf.ShowDataDisplayFontShadow, gf.ShowDataDisplayFontOutline, (int)rectangleF.Left, (int)rectangleF.Top, (int)rectangleF.Width, 0);
						rectangleF = new RectangleF((float)(fS_Width - num15), (float)(num11 + num10 / 2), (float)num15, (float)num10);
						gf.OutputOneLineToScreen(InItem, text4, font, g, inColour, stringFormat.Alignment, gf.ShowDataDisplayFontShadow, gf.ShowDataDisplayFontOutline, (int)rectangleF.Left, (int)rectangleF.Top, (int)rectangleF.Width, 0);
						num3 = ((num14 > num15) ? num14 : num15);
					}
					stringFormat.Alignment = StringAlignment.Near;
					int num17 = 4;
					RectangleF rect_slidesinfo = new RectangleF(0f, (float)num11, (float)(fS_Width - (num3 + num17)), (float)num10);
					num8 = gf.DP_SetSlideIndicators(InItem, ref InPictureBox, ref g, font, rect_slidesinfo) - num17;
					int num18 = fS_Top + fS_Height / 2;
					num = gf.DisplayFontSize(num, gf.Buffer_LS_Width, 3, 1);
					num9 = ((gf.ShowDataDisplayTitle > 0) ? (num * 7 / 8) : num);
					if (num9 < 1)
					{
						num9 = 1;
					}
					font = new Font(songLyrics.FS_Font.Name, (float)num9, songLyrics.FS_Font.Style);
					bool flag = false;
					int num19 = fS_Height;
					if ((gf.ShowDataDisplayCopyright > 0 || InItem.Show_LicAdim) && text != "")
					{
						int num20 = (int)(g.MeasureString(text, font, 10000).Width * num4);
						if (num20 > num8 - num2)
						{
							gf.ReduceFontToFit(g, text, ref font, num8 - num2, fS_Height / 2, true);
						}
						RectangleF rectangleF2 = new RectangleF((float)(num2 + num17), (float)num18, (float)(num8 - num2), (float)(fS_Height / 2 + 2));
						int num21 = gf.OutputOneLineToScreen(InItem, text, font, g, inColour, stringFormat.Alignment, gf.ShowDataDisplayFontShadow, gf.ShowDataDisplayFontOutline, (int)rectangleF2.Left, (int)rectangleF2.Top, (int)rectangleF2.Width, fS_Height / 2);
						num19 = num21 - fS_Top;
						num18 = num21 - num19;
						flag = true;
					}
					else
					{
						num18 = fS_Top;
					}
					int num22 = fS_Height * 10 / 100;
					num19 -= num22;
					num18 += num22;
					font = new Font(songLyrics.FS_Font.Name, (float)(num * 12 / 10), songLyrics.FS_Font.Style);
					if (gf.ShowDataDisplayTitle > 0)
					{
						string title = InItem.Title;
						int num23 = (int)(g.MeasureString(title, font, 10000).Width * num4);
						num19 = ((num19 > 2) ? (num19 - 2) : 2);
						if (num23 > num8)
						{
							gf.ReduceFontToFit(g, title, ref font, num8 - num2, num19, !flag);
						}
						if (font.Size >= 25f)
						{
							num18 -= 3;
						}
						else
						{
							if (font.Size <= 21f)
							{
								num18 += 2;
							}
						}
						RectangleF rectangleF3 = new RectangleF((float)(num2 + num17), (float)(num18 + (flag ? 3 : -2)), (float)(num8 - num2), (float)num19);
						gf.OutputOneLineToScreen(InItem, title, font, g, inColour, stringFormat.Alignment, gf.ShowDataDisplayFontShadow, gf.ShowDataDisplayFontOutline, (int)rectangleF3.Left, (int)rectangleF3.Top, (int)rectangleF3.Width, num19);
					}
					InItem.Show_LicAdim = false;
				}
				else
				{
					if (InItem.Show_LicAdim)
					{
						int num18 = fS_Top + fS_Height / 2;
						RectangleF rectangleF2 = new RectangleF((float)num2, (float)num18, (float)fS_Width, (float)(fS_Height / 2));
						gf.OutputOneLineToScreen(InItem, text, font, g, inColour, stringFormat.Alignment, gf.ShowDataDisplayFontShadow, gf.ShowDataDisplayFontOutline, (int)rectangleF2.Left, (int)rectangleF2.Top, (int)rectangleF2.Width, 0);
						InItem.Show_LicAdim = false;
					}
				}
			}
		}
		public static void LoadRegistryMainEditHistory()
		{
			gf.MaxUserEditHistory = gf.GetRegValue("options", "MaxEditHistory", 10);
			if (gf.MaxUserEditHistory < 0 | gf.MaxUserEditHistory > gf.AbsoluteMaxHitoryItems)
			{
				gf.MaxUserEditHistory = gf.AbsoluteMaxHitoryItems;
			}
			for (int i = 1; i <= gf.AbsoluteMaxHitoryItems; i++)
			{
				gf.MainEditHistoryList[i, 0] = "";
			}
			gf.TotalMainEditHistory = gf.AbsoluteMaxHitoryItems;
			for (int i = gf.AbsoluteMaxHitoryItems; i >= 1; i--)
			{
				gf.MainEditHistoryList[i, 0] = gf.GetRegValue("maineditlist", i.ToString(), "");
				if (gf.MainEditHistoryList[i, 0] == "")
				{
					gf.TotalMainEditHistory = i - 1;
				}
			}
			gf.ValidateMainHistoryItems();
		}
		public static void ValidateMainHistoryItems()
		{
			int num = 0;
			if (gf.TotalMainEditHistory < 0 | gf.TotalMainEditHistory > gf.AbsoluteMaxHitoryItems)
			{
				gf.TotalMainEditHistory = gf.AbsoluteMaxHitoryItems;
			}
			for (int i = 1; i <= gf.TotalMainEditHistory; i++)
			{
				if (gf.GetItemTitle(gf.MainEditHistoryList[i, 0]) != "")
				{
					num++;
					gf.MainEditHistoryList[num, 0] = gf.MainEditHistoryList[i, 0];
				}
			}
			gf.TotalMainEditHistory = num;
			gf.RemoveDuplicateEditorHistoryItems(ref gf.MainEditHistoryList, ref gf.TotalMainEditHistory);
		}
		public static void LoadRegistryEditorEditHistory()
		{
			gf.MaxUserEditHistory = gf.GetRegValue("options", "MaxEditHistory", 10);
			if (gf.MaxUserEditHistory < 0 | gf.MaxUserEditHistory > gf.AbsoluteMaxHitoryItems)
			{
				gf.MaxUserEditHistory = gf.AbsoluteMaxHitoryItems;
			}
			for (int i = 1; i <= gf.AbsoluteMaxHitoryItems; i++)
			{
				gf.EditorEditHistoryList[i, 0] = "";
			}
			gf.TotalEditorEditHistory = gf.AbsoluteMaxHitoryItems;
			for (int i = gf.AbsoluteMaxHitoryItems; i >= 1; i--)
			{
				gf.EditorEditHistoryList[i, 0] = gf.GetRegValue("editoreditlist", i.ToString(), "");
				if (gf.EditorEditHistoryList[i, 0] == "")
				{
					gf.TotalEditorEditHistory = i - 1;
				}
			}
			gf.ValidateEditorHistoryItems();
		}
		public static void ValidateEditorHistoryItems()
		{
			int num = 0;
			for (int i = 1; i <= gf.TotalEditorEditHistory; i++)
			{
				if (gf.GetItemTitle(gf.EditorEditHistoryList[i, 0]) != "")
				{
					num++;
					gf.EditorEditHistoryList[num, 0] = gf.EditorEditHistoryList[i, 0];
				}
			}
			gf.TotalEditorEditHistory = num;
			gf.RemoveDuplicateEditorHistoryItems(ref gf.EditorEditHistoryList, ref gf.TotalEditorEditHistory);
		}
		public static void LoadRegistryInfoScreenEditHistory()
		{
			gf.MaxUserEditHistory = gf.GetRegValue("options", "MaxEditHistory", 10);
			if (gf.MaxUserEditHistory < 0 | gf.MaxUserEditHistory > gf.AbsoluteMaxHitoryItems)
			{
				gf.MaxUserEditHistory = gf.AbsoluteMaxHitoryItems;
			}
			for (int i = 1; i <= gf.AbsoluteMaxHitoryItems; i++)
			{
				gf.InfoScreenEditHistoryList[i, 0] = "";
			}
			gf.TotalInfoScreenEditHistory = gf.MaxUserEditHistory;
			for (int i = gf.AbsoluteMaxHitoryItems; i >= 1; i--)
			{
				gf.InfoScreenEditHistoryList[i, 0] = gf.GetRegValue("infoscreeneditlist", i.ToString(), "");
				if (gf.InfoScreenEditHistoryList[i, 0] == "")
				{
					gf.TotalInfoScreenEditHistory = i - 1;
				}
			}
			gf.ValidateInfoScreenHistoryItems();
		}
		public static void ValidateInfoScreenHistoryItems()
		{
			int num = 0;
			for (int i = 1; i <= gf.TotalInfoScreenEditHistory; i++)
			{
				if (gf.GetItemTitle(gf.InfoScreenEditHistoryList[i, 0]) != "")
				{
					num++;
					gf.InfoScreenEditHistoryList[num, 0] = gf.InfoScreenEditHistoryList[i, 0];
				}
			}
			gf.TotalInfoScreenEditHistory = num;
			gf.RemoveDuplicateEditorHistoryItems(ref gf.InfoScreenEditHistoryList, ref gf.TotalInfoScreenEditHistory);
		}
		public static string GetItemTitle(string InIDString)
		{
			InIDString = gf.Trim(InIDString);
			string result;
			if (InIDString == "")
			{
				result = "";
			}
			else
			{
				string a = gf.Left(InIDString, 1);
				string text = gf.Mid(InIDString, 1);
				string text2 = "";
				if (a == "D")
				{
					try
					{
						string fullSearchString = "select * from SONG where songid=" + text;
						Recordset recordSet = gf.GetRecordSet(gf.ConnectStringMainDB, fullSearchString);
						if (recordSet != null && !recordSet.EOF)
						{
							if (gf.GetDataInt(recordSet, "FolderNo") > 0 && gf.FolderUse[gf.GetDataInt(recordSet, "FolderNo")] > 0)
							{
								text2 = gf.GetDataString(recordSet, "Title_1");
							}
						}
					}
					catch
					{
					}
				}
				else
				{
					if (a == "P")
					{
						text2 = text;
					}
					else
					{
						if (!(a == "B"))
						{
							if (a == "T")
							{
								text2 = text;
							}
							else
							{
								if (a == "I")
								{
									text2 = text;
									gf.GetDisplayNameOnly(ref text2, true);
								}
								else
								{
									if (a == "W")
									{
										text2 = text;
									}
									else
									{
										if (a == "M")
										{
											text2 = text;
										}
									}
								}
							}
						}
					}
				}
				result = text2;
			}
			return result;
		}
		public static void SaveMainEditHistoryToRegistry()
		{
			gf.SaveRegValue("options", "MaxEditHistory", gf.MaxUserEditHistory);
			if (gf.TotalMainEditHistory > gf.MaxUserEditHistory)
			{
				gf.TotalMainEditHistory = gf.MaxUserEditHistory;
			}
			for (int i = 1; i <= gf.AbsoluteMaxHitoryItems; i++)
			{
				if (i <= gf.TotalMainEditHistory)
				{
					gf.SaveRegValue("maineditlist", i.ToString(), gf.MainEditHistoryList[i, 0]);
				}
				else
				{
					gf.SaveRegValue("maineditlist", i.ToString(), "");
					gf.MainEditHistoryList[i, 0] = "";
				}
			}
		}
		public static void RemoveDuplicateEditorHistoryItems(ref string[,] InEditHistoryList, ref int InTotalEditorEditHistory)
		{
			int num = (InTotalEditorEditHistory <= gf.AbsoluteMaxHitoryItems) ? InTotalEditorEditHistory : gf.AbsoluteMaxHitoryItems;
			int num2 = 0;
			for (int i = 1; i <= gf.AbsoluteMaxHitoryItems; i++)
			{
				gf.TempEditHistoryList[i, 0] = "";
				gf.TempEditHistoryList[i, 1] = "";
			}
			for (int i = 1; i <= num; i++)
			{
				if (i == 1)
				{
					num2 = 1;
					gf.TempEditHistoryList[1, 0] = InEditHistoryList[1, 0];
					gf.TempEditHistoryList[1, 1] = InEditHistoryList[1, 1];
				}
				else
				{
					bool flag = false;
					for (int j = 1; j <= num2; j++)
					{
						if (InEditHistoryList[i, 0] == gf.TempEditHistoryList[j, 0])
						{
							flag = true;
						}
					}
					if (!flag)
					{
						num2++;
						gf.TempEditHistoryList[num2, 0] = InEditHistoryList[i, 0];
						gf.TempEditHistoryList[num2, 1] = InEditHistoryList[i, 1];
					}
				}
			}
			for (int i = 1; i <= gf.AbsoluteMaxHitoryItems; i++)
			{
				InEditHistoryList[i, 0] = gf.TempEditHistoryList[i, 0];
				InEditHistoryList[i, 1] = gf.TempEditHistoryList[i, 1];
			}
			InTotalEditorEditHistory = num2;
		}
		public static void SaveEditorEditHistoryToRegistry()
		{
			gf.SaveRegValue("options", "MaxEditHistory", gf.MaxUserEditHistory);
			if (gf.TotalEditorEditHistory > gf.MaxUserEditHistory)
			{
				gf.TotalEditorEditHistory = gf.MaxUserEditHistory;
			}
			for (int i = 1; i <= gf.AbsoluteMaxHitoryItems; i++)
			{
				if (i <= gf.TotalEditorEditHistory)
				{
					gf.SaveRegValue("editoreditlist", i.ToString(), gf.EditorEditHistoryList[i, 0]);
				}
				else
				{
					gf.SaveRegValue("editoreditlist", i.ToString(), "");
					gf.EditorEditHistoryList[i, 0] = "";
				}
			}
		}
		public static void SaveInfoScreenEditHistoryToRegistry()
		{
			gf.SaveRegValue("options", "MaxEditHistory", gf.MaxUserEditHistory);
			if (gf.TotalInfoScreenEditHistory > gf.MaxUserEditHistory)
			{
				gf.TotalInfoScreenEditHistory = gf.MaxUserEditHistory;
			}
			for (int i = 1; i <= gf.AbsoluteMaxHitoryItems; i++)
			{
				if (i <= gf.TotalInfoScreenEditHistory)
				{
					gf.SaveRegValue("infoscreeneditlist", i.ToString(), gf.InfoScreenEditHistoryList[i, 0]);
				}
				else
				{
					gf.SaveRegValue("infoscreeneditlist", i.ToString(), "");
					gf.InfoScreenEditHistoryList[i, 0] = "";
				}
			}
		}
		public static int DP_SetSlideIndicators(gf.SongSettings InItem, ref ImageTransitionControl InPic, ref Graphics g, Font tempFont, RectangleF rect_slidesinfo)
		{
			int num = (InItem.Source == gf.ItemSource.WorshipList) ? InItem.CurItemNo : 0;
			int totalWorshipListItems = gf.TotalWorshipListItems;
			Color color = (gf.PanelTextColourAsRegion1 > 0) ? InItem.Lyrics[3].ForeColour : gf.PanelTextColour;
			StringFormat stringFormat = new StringFormat();
			FontStyle fontStyle = FontStyle.Regular;
			if (gf.ShowDataDisplayFontBold > 0)
			{
				fontStyle |= FontStyle.Bold;
			}
			if (gf.ShowDataDisplayFontItalic > 0)
			{
				fontStyle |= FontStyle.Italic;
			}
			tempFont = new Font(tempFont.Name, tempFont.Size, fontStyle);
			int num2 = (int)g.MeasureString("1", tempFont, 10000).Height;
			int num3 = (int)(rect_slidesinfo.Top + rect_slidesinfo.Height / 20f);
			int num4 = (int)(rect_slidesinfo.Top + rect_slidesinfo.Height / 2f);
			int num5 = num4 - num2 / 20;
			int num7;
			if (gf.ShowDataDisplaySlides > 0)
			{
				int num6 = gf.DataDisplaySlides(InItem, ref g, tempFont, color, rect_slidesinfo, num3, num4, num5, 0, false);
				num7 = (int)rect_slidesinfo.Width - num6;
				gf.DataDisplaySlides(InItem, ref g, tempFont, color, rect_slidesinfo, num3, num4, num5, num7, true);
				num7 -= (int)g.MeasureString("1", tempFont, 10000).Width;
			}
			else
			{
				num7 = (int)rect_slidesinfo.Width;
			}
			if (gf.ShowDataDisplaySongs > 0)
			{
				string text = (num > 0) ? num.ToString() : "A";
				int num8 = (int)g.MeasureString(text, tempFont, 10000).Width;
				string text2 = totalWorshipListItems.ToString();
				int num9 = (int)g.MeasureString(text2, tempFont, 10000).Width;
				num7 -= num9;
				gf.OutputOneLineToScreen(InItem, text, tempFont, g, color, stringFormat.Alignment, gf.ShowDataDisplayFontShadow, gf.ShowDataDisplayFontOutline, num7 + (num9 - num8) / 2, num3, num7 + num9, 0);
				gf.OutputOneLineToScreen(InItem, text2, tempFont, g, color, stringFormat.Alignment, gf.ShowDataDisplayFontShadow, gf.ShowDataDisplayFontOutline, num7, num4, num7 + num9, 0);
				g.DrawLine(new Pen(color), num7, num5, num7 + num9, num5);
			}
			return num7;
		}
		public static int DataDisplaySlides(gf.SongSettings InItem, ref Graphics g, Font tempFont, Color In_TextColour, RectangleF rect_slidesinfo, int VersesSymOffsetTop, int SlidesSymOffsetTop, int RectOffsetTop, int OffsetLeft, bool DisplayIndicators)
		{
			int curSlide = InItem.CurSlide;
			int totalSlides = InItem.TotalSlides;
			StringFormat stringFormat = new StringFormat();
			int arg_31_0 = (totalSlides <= 10) ? totalSlides : 11;
			int num = (curSlide - 1) / 10 * 10 + 1;
			int num2 = (totalSlides > num + 9) ? (num + 9) : totalSlides;
			int num3 = num2 - num + 1;
			int num4 = OffsetLeft;
			for (int i = 1; i <= 11; i++)
			{
				string extractedText = "";
				string text = "";
				bool flag = false;
				if (i <= num3)
				{
					int num5 = num + i - 1;
					text = ((num5 < 10) ? " " : "") + num5.ToString("0") + " ";
					flag = (curSlide == num5);
					if ((InItem.Slide[num5, 0] >= 0 & InItem.Slide[num5, 0] <= 10) | (InItem.Slide[num5, 0] >= 100 & InItem.Slide[num5, 0] <= 112))
					{
						extractedText = " " + gf.ConvertSequenceSymbol(gf.SequenceSymbol[InItem.Slide[num5, 0]]);
					}
				}
				else
				{
					if (i == 11 & totalSlides > num2)
					{
						text = ".. " + totalSlides.ToString("00");
					}
				}
				int num6 = (int)g.MeasureString(text, tempFont, 10000).Width;
				if (DisplayIndicators)
				{
					Color inColour;
					if (flag)
					{
						g.DrawRectangle(new Pen(In_TextColour), (float)(OffsetLeft + 1), (float)RectOffsetTop, (float)(num6 + 1), rect_slidesinfo.Height * 2f / 5f);
					}
					else
					{
						inColour = Color.White;
					}
					inColour = (flag ? Color.Red : In_TextColour);
					gf.OutputOneLineToScreen(InItem, extractedText, tempFont, g, inColour, stringFormat.Alignment, gf.ShowDataDisplayFontShadow, gf.ShowDataDisplayFontOutline, OffsetLeft, VersesSymOffsetTop, OffsetLeft + num6, 0);
					gf.OutputOneLineToScreen(InItem, text, tempFont, g, inColour, stringFormat.Alignment, gf.ShowDataDisplayFontShadow, gf.ShowDataDisplayFontOutline, OffsetLeft, SlidesSymOffsetTop, OffsetLeft + num6, 0);
				}
				OffsetLeft += num6;
			}
			num4 = OffsetLeft - num4;
			OffsetLeft += (int)g.MeasureString("A", tempFont, 10000).Width;
			return num4;
		}
		public static string ConvertSequenceSymbol(string InSymbol)
		{
			string result;
			if (InSymbol == gf.SequenceSymbol[103])
			{
				result = gf.SequenceSymbol[100].ToUpper();
			}
			else
			{
				if (InSymbol == gf.SequenceSymbol[102])
				{
					result = gf.SequenceSymbol[0].ToUpper();
				}
				else
				{
					if (InSymbol == gf.SequenceSymbol[112])
					{
						result = gf.SequenceSymbol[111].ToUpper();
					}
					else
					{
						result = InSymbol;
					}
				}
			}
			return result;
		}
		public static string GetCJKTitle(string InTitle, gf.SortBy CJKMode)
		{
			string text = null;
			return gf.GetCJKTitle(InTitle, CJKMode, ref text);
		}
		public static string GetCJKTitle(string InTitle, gf.SortBy CJKMode, ref string FirstCharSym)
		{
			string result;
			if (InTitle == "")
			{
				FirstCharSym = "";
				result = "";
			}
			else
			{
				string text = "";
				if (CJKMode == gf.SortBy.WordCount)
				{
					text = gf.CJK_WordCount(InTitle);
				}
				if (FirstCharSym != null)
				{
					int num = (int)InTitle[0];
					if (num < 0)
					{
						num += 65536;
					}
					int num2 = gf.StrokeCount[num];
					if (num2 > 0)
					{
						if (text != "")
						{
							FirstCharSym = text;
						}
						else
						{
							FirstCharSym = num2.ToString("00");
						}
					}
					else
					{
						FirstCharSym = " " + gf.Left(InTitle, 1);
					}
				}
				text += gf.CJK_StrokeCount(InTitle);
				if (text.Length > 100)
				{
					text = gf.Left(text, 100);
				}
				result = text;
			}
			return result;
		}
		public static string CJK_WordCount(string DName)
		{
			string result;
			if (DName == "" || (gf.StringToInt(DName[0]) > 0 & gf.StringToInt(DName[0]) < 128))
			{
				result = "000";
			}
			else
			{
				int num = DName.IndexOf("(") - 1;
				if (num < 0)
				{
					num = DName.Length;
				}
				int num2 = DName.IndexOf(" ") - 1;
				if (num2 > 0 & num2 < num)
				{
					num = num2;
				}
				result = num.ToString("000");
			}
			return result;
		}
		public static string CJK_StrokeCount(string DName)
		{
			string text = "";
			int num = 0;
			long num2 = (long)((DName == "") ? 0 : gf.StringToInt(DName[0]));
			if (num2 < 0L)
			{
				num2 += 65536L;
			}
			int num3 = gf.StrokeCount[(int)checked((IntPtr)num2)];
			if (num3 > 0)
			{
				text = text + num3.ToString("00") + num2.ToString("00000");
				DName = gf.Right(DName, DName.Length - 1);
				while (DName.Length > 0)
				{
					num++;
					if (num < 6)
					{
						num2 = (long)DName[0];
						if (num2 < 0L)
						{
							num2 += 65536L;
						}
						num3 = gf.StrokeCount[(int)checked((IntPtr)num2)];
						if (num3 > 0)
						{
							text = text + num3.ToString("00") + num2.ToString("00000");
						}
						else
						{
							text = text + "00" + num2.ToString("00000");
						}
						DName = gf.Right(DName, DName.Length - 1);
					}
					else
					{
						text += DName;
						DName = "";
					}
				}
				if (text.Length > 100)
				{
					text = gf.Left(text, 100);
				}
			}
			else
			{
				text = "000" + DName;
			}
			return text;
		}
		public static string Format6(string InString)
		{
			InString = gf.Trim(InString);
			string result;
			if (InString.Length == 0)
			{
				result = "000000";
			}
			else
			{
				if (InString.Length == 1)
				{
					result = "00000" + InString;
				}
				else
				{
					if (InString.Length == 2)
					{
						result = "0000" + InString;
					}
					else
					{
						if (InString.Length == 3)
						{
							result = "000" + InString;
						}
						else
						{
							if (InString.Length == 4)
							{
								result = "00" + InString;
							}
							else
							{
								if (InString.Length == 5)
								{
									result = "0" + InString;
								}
								else
								{
									result = gf.Left(InString, 6);
								}
							}
						}
					}
				}
			}
			return result;
		}
		public static bool SaveIndexFile(string InFileName, ref ListView InList, gf.UsageMode InMode, bool SaveAllItems, string InFormatString, string InNotes)
		{
			StringBuilder stringBuilder = new StringBuilder();
			bool result;
			try
			{
				XmlTextWriter xmlTextWriter = new XmlTextWriter(InFileName, Encoding.UTF8);
				xmlTextWriter.Formatting = Formatting.Indented;
				xmlTextWriter.WriteStartDocument();
				xmlTextWriter.WriteStartElement("EasiSlides");
				xmlTextWriter.WriteStartElement("ListItem");
				gf.WriteXMLSessionHeader(ref xmlTextWriter, InFormatString, InNotes);
				string text = "";
				string text2 = "";
				string value = "";
				int num = SaveAllItems ? InList.Items.Count : 0;
				for (int i = 1; i <= num; i++)
				{
					string value2 = "";
					switch (InMode)
					{
					case gf.UsageMode.Worship:
					{
						text = gf.Trim(InList.Items[i - 1].SubItems[1].Text);
						string text3 = gf.Left(text, 1);
						string text4 = text3;
						if (text4 == null)
						{
							goto IL_1B0;
						}
						if (!(text4 == "D"))
						{
							if (!(text4 == "B"))
							{
								goto IL_1B0;
							}
							text2 = gf.Trim(InList.Items[i - 1].Text);
							text = "B" + gf.Mid(text, 1);
						}
						else
						{
							text2 = gf.RemoveMusicSym(gf.Trim(InList.Items[i - 1].Text));
							if (gf.Right(text2, " <Error - Item Not Found>".Length) == " <Error - Item Not Found>")
							{
								text2 = gf.Left(text2, text2.Length - " <Error - Item Not Found>".Length);
							}
							value2 = InList.Items[i - 1].SubItems[7].Text;
						}
						IL_1C8:
						value = gf.Trim(InList.Items[i - 1].SubItems[2].Text);
						break;
						IL_1B0:
						text2 = gf.Mid(text, 1);
						text = text3 + "1";
						goto IL_1C8;
					}
					case gf.UsageMode.PraiseBook:
						text = gf.Trim(InList.Items[i - 1].SubItems[3].Text);
						text2 = gf.RemoveMusicSym(gf.Trim(InList.Items[i - 1].SubItems[2].Text));
						value = InList.Items[i - 1].SubItems[5].Text;
						break;
					}
					xmlTextWriter.WriteStartElement("Item");
					xmlTextWriter.WriteElementString("ItemID", text);
					xmlTextWriter.WriteElementString("Title1", text2);
					xmlTextWriter.WriteElementString("Folder", value2);
					xmlTextWriter.WriteElementString("FormatData", value);
					xmlTextWriter.WriteEndElement();
				}
				xmlTextWriter.WriteEndDocument();
				xmlTextWriter.Flush();
				xmlTextWriter.Close();
				result = true;
			}
			catch
			{
				result = false;
			}
			return result;
		}
		public static void WriteXMLSessionHeader(ref XmlTextWriter xtw, string InFormatString, string InNotes)
		{
			int num = gf.MediaMute + gf.MediaRepeat * 2 + gf.MediaWidescreen * 4;
			StringBuilder stringBuilder = new StringBuilder();
			if (InFormatString != "")
			{
				stringBuilder.Append(InFormatString);
			}
			else
			{
				stringBuilder.Append(string.Concat(new object[]
				{
					Convert.ToString(11),
					"=",
					Convert.ToString(gf.PanelBackColour.ToArgb()),
					'>'
				}));
				stringBuilder.Append(string.Concat(new object[]
				{
					Convert.ToString(12),
					"=",
					Convert.ToString(gf.PanelBackColourTransparent),
					'>'
				}));
				stringBuilder.Append(string.Concat(new object[]
				{
					Convert.ToString(13),
					"=",
					Convert.ToString(gf.PanelTextColour.ToArgb()),
					'>'
				}));
				stringBuilder.Append(string.Concat(new object[]
				{
					Convert.ToString(14),
					"=",
					Convert.ToString(gf.PanelTextColourAsRegion1),
					'>'
				}));
				stringBuilder.Append(string.Concat(new object[]
				{
					Convert.ToString(15),
					"=",
					Convert.ToString(gf.ShowDataDisplayMode + gf.ShowDataDisplaySlides * 2 + gf.ShowDataDisplaySongs * 4 + gf.ShowDataDisplayTitle * 8 + gf.ShowDataDisplayCopyright * 16 + gf.ShowDataDisplayPrevNext * 32),
					'>'
				}));
				stringBuilder.Append(string.Concat(new object[]
				{
					Convert.ToString(16),
					"=",
					Convert.ToString((int)(gf.BottomBorderFactor * 100.0)),
					'>'
				}));
				stringBuilder.Append(string.Concat(new object[]
				{
					Convert.ToString(17),
					"=",
					gf.ShowDataDisplayFontName,
					'>'
				}));
				stringBuilder.Append(string.Concat(new object[]
				{
					Convert.ToString(18),
					"=",
					Convert.ToString(gf.ShowDataDisplayFontBold + gf.ShowDataDisplayFontItalic * 2 + gf.ShowDataDisplayFontUnderline * 4 + gf.ShowDataDisplayFontShadow * 8 + gf.ShowDataDisplayFontOutline * 16),
					'>'
				}));
				stringBuilder.Append(string.Concat(new object[]
				{
					Convert.ToString(19),
					"=",
					Convert.ToString(gf.ShowDataDisplayIndicatorsFontSize),
					'>'
				}));
				stringBuilder.Append(string.Concat(new object[]
				{
					Convert.ToString(21),
					"=",
					Convert.ToString(gf.ShowSongHeadings),
					'>'
				}));
				stringBuilder.Append(string.Concat(new object[]
				{
					Convert.ToString(23),
					"=",
					Convert.ToString(gf.ShowSongHeadingsAlign),
					'>'
				}));
				stringBuilder.Append(string.Concat(new object[]
				{
					Convert.ToString(22),
					"=",
					Convert.ToString(gf.UseShadowFont * 2 + gf.ShowNotations * 4 + gf.ShowCapoZero * 8 + gf.ShowInterlace * 16 + gf.UseOutlineFont * 32),
					'>'
				}));
				stringBuilder.Append(string.Concat(new object[]
				{
					Convert.ToString(25),
					"=",
					Convert.ToString(gf.ShowLyrics),
					'>'
				}));
				stringBuilder.Append(string.Concat(new object[]
				{
					Convert.ToString(26),
					"=",
					Convert.ToString(gf.ShowScreenColour[0].ToArgb()),
					'>'
				}));
				stringBuilder.Append(string.Concat(new object[]
				{
					Convert.ToString(27),
					"=",
					Convert.ToString(gf.ShowScreenColour[1].ToArgb()),
					'>'
				}));
				stringBuilder.Append(string.Concat(new object[]
				{
					Convert.ToString(28),
					"=",
					gf.ShowScreenStyle.ToString(),
					'>'
				}));
				stringBuilder.Append(string.Concat(new object[]
				{
					Convert.ToString(29),
					"=",
					Convert.ToString(gf.ShowFontColour[0].ToArgb()),
					'>'
				}));
				stringBuilder.Append(string.Concat(new object[]
				{
					Convert.ToString(30),
					"=",
					Convert.ToString(gf.ShowFontColour[1].ToArgb()),
					'>'
				}));
				stringBuilder.Append(string.Concat(new object[]
				{
					Convert.ToString(31),
					"=",
					Convert.ToString(gf.ShowFontAlign[0, 0]),
					'>'
				}));
				stringBuilder.Append(string.Concat(new object[]
				{
					Convert.ToString(32),
					"=",
					Convert.ToString(gf.ShowFontAlign[0, 1]),
					'>'
				}));
				stringBuilder.Append(string.Concat(new object[]
				{
					Convert.ToString(50),
					"=",
					Convert.ToString(gf.MediaOption),
					'>'
				}));
				stringBuilder.Append(string.Concat(new object[]
				{
					Convert.ToString(51),
					"=",
					gf.MediaLocation,
					'>'
				}));
				stringBuilder.Append(string.Concat(new object[]
				{
					Convert.ToString(52),
					"=",
					Convert.ToString(gf.MediaVolume),
					'>'
				}));
				stringBuilder.Append(string.Concat(new object[]
				{
					Convert.ToString(53),
					"=",
					Convert.ToString(gf.MediaBalance),
					'>'
				}));
				stringBuilder.Append(string.Concat(new object[]
				{
					Convert.ToString(54),
					"=",
					num.ToString(),
					'>'
				}));
				stringBuilder.Append(string.Concat(new object[]
				{
					Convert.ToString(55),
					"=",
					gf.MediaCaptureDeviceNumber.ToString(),
					'>'
				}));
				stringBuilder.Append(string.Concat(new object[]
				{
					Convert.ToString(61),
					"=",
					gf.BackgroundPicture,
					'>'
				}));
				stringBuilder.Append(string.Concat(new object[]
				{
					Convert.ToString(62),
					"=",
					Convert.ToString((int)gf.BackgroundMode),
					'>'
				}));
				stringBuilder.Append(string.Concat(new object[]
				{
					Convert.ToString(63),
					"=",
					Convert.ToString(gf.ShowVerticalAlign),
					'>'
				}));
				stringBuilder.Append(string.Concat(new object[]
				{
					Convert.ToString(64),
					"=",
					Convert.ToString(gf.ShowLeftMargin[0]),
					'>'
				}));
				stringBuilder.Append(string.Concat(new object[]
				{
					Convert.ToString(65),
					"=",
					Convert.ToString(gf.ShowRightMargin[0]),
					'>'
				}));
				stringBuilder.Append(string.Concat(new object[]
				{
					Convert.ToString(66),
					"=",
					Convert.ToString(gf.ShowBottomMargin[0]),
					'>'
				}));
				stringBuilder.Append(string.Concat(new object[]
				{
					Convert.ToString(72),
					"=",
					gf.GlobalImageCanvas.GetTransitionText(gf.ShowItemTransition),
					'>'
				}));
				stringBuilder.Append(string.Concat(new object[]
				{
					Convert.ToString(73),
					"=",
					gf.GlobalImageCanvas.GetTransitionText(gf.ShowSlideTransition),
					'>'
				}));
				for (int i = 0; i < 8; i++)
				{
					int num2 = 101 + i * 5;
					stringBuilder.Append(string.Concat(new object[]
					{
						num2.ToString(),
						"=",
						Convert.ToString(gf.PB_ShowWords[i] + gf.PB_WordsBold[i] * 2 + gf.PB_WordsItalic[i] * 4 + gf.PB_WordsUnderline[i] * 8),
						'>'
					}));
					stringBuilder.Append(string.Concat(new object[]
					{
						Convert.ToString(num2 + 1),
						"=",
						gf.PB_WordsSize[i].ToString(),
						'>'
					}));
					stringBuilder.Append(string.Concat(new object[]
					{
						Convert.ToString(num2 + 2),
						"=",
						Convert.ToString(gf.PB_WordsColour[i].ToArgb()),
						'>'
					}));
				}
				stringBuilder.Append(string.Concat(new object[]
				{
					Convert.ToString(151),
					"=",
					Convert.ToString(gf.PB_ShowHeadings[0] + gf.PB_ShowHeadings[1] * 2 + gf.PB_ShowHeadings[2] * 4 + gf.PB_ShowHeadings[3] * 8),
					'>'
				}));
				stringBuilder.Append(string.Concat(new object[]
				{
					Convert.ToString(153),
					"=",
					Convert.ToString(gf.PB_LyricsPattern),
					'>'
				}));
				stringBuilder.Append(string.Concat(new object[]
				{
					Convert.ToString(154),
					"=",
					Convert.ToString(gf.PB_ShowSection),
					'>'
				}));
				stringBuilder.Append(string.Concat(new object[]
				{
					Convert.ToString(155),
					"=",
					Convert.ToString(gf.PB_ShowColumns),
					'>'
				}));
				stringBuilder.Append(string.Concat(new object[]
				{
					Convert.ToString(156),
					"=",
					Convert.ToString(gf.PB_PageSize),
					'>'
				}));
				stringBuilder.Append(string.Concat(new object[]
				{
					Convert.ToString(170),
					"=",
					Convert.ToString(gf.PB_Spacing[0]),
					'>'
				}));
				stringBuilder.Append(string.Concat(new object[]
				{
					Convert.ToString(171),
					"=",
					Convert.ToString(gf.PB_Spacing[1]),
					'>'
				}));
				stringBuilder.Append(string.Concat(new object[]
				{
					Convert.ToString(172),
					"=",
					Convert.ToString(gf.PB_ShowScreenBreaks),
					'>'
				}));
				stringBuilder.Append(string.Concat(new object[]
				{
					Convert.ToString(173),
					"=",
					Convert.ToString(gf.PB_OneSongPerPage),
					'>'
				}));
				stringBuilder.Append(string.Concat(new object[]
				{
					Convert.ToString(174),
					"=",
					Convert.ToString(gf.PB_CJKGroupStyle),
					'>'
				}));
				stringBuilder.Append(string.Concat(new object[]
				{
					Convert.ToString(180),
					"=",
					Convert.ToString(gf.PB_ShowNotations + gf.PB_ShowTiming * 2 + gf.PB_ShowKey * 4 + gf.PB_ShowCapo * 8 + gf.PB_CapoZero * 16),
					'>'
				}));
			}
			xtw.WriteStartElement("ListHeader");
			xtw.WriteElementString("SystemID", gf.SystemID);
			xtw.WriteElementString("FormatData", stringBuilder.ToString());
			xtw.WriteElementString("Notes", InNotes);
			xtw.WriteEndElement();
		}
		public static void SaveIndexFileOld(string OutFileName, ref ListView InList, gf.UsageMode InMode)
		{
			try
			{
				FileStream fileStream = new FileStream(OutFileName, FileMode.Create);
				BinaryWriter binaryWriter = new BinaryWriter(fileStream);
				binaryWriter.Write(255);
				binaryWriter.Write(254);
				string inString = "[";
				gf.WriteStringToBinaryFile(ref binaryWriter, inString);
				inString = string.Concat(new object[]
				{
					'\u0001',
					"=",
					Convert.ToString(320),
					'>'
				});
				gf.WriteStringToBinaryFile(ref binaryWriter, inString);
				inString = string.Concat(new object[]
				{
					'\u0002',
					"=",
					Convert.ToString(gf.PanelBackColour.ToArgb()),
					'>'
				});
				gf.WriteStringToBinaryFile(ref binaryWriter, inString);
				inString = string.Concat(new object[]
				{
					'\u0003',
					"=",
					Convert.ToString(gf.PanelBackColourTransparent),
					'>'
				});
				gf.WriteStringToBinaryFile(ref binaryWriter, inString);
				inString = string.Concat(new object[]
				{
					'\u0004',
					"=",
					Convert.ToString(gf.PanelTextColour.ToArgb()),
					'>'
				});
				gf.WriteStringToBinaryFile(ref binaryWriter, inString);
				inString = string.Concat(new object[]
				{
					'\u0005',
					"=",
					Convert.ToString(gf.PanelTextColourAsRegion1),
					'>'
				});
				gf.WriteStringToBinaryFile(ref binaryWriter, inString);
				inString = string.Concat(new object[]
				{
					'\u0006',
					"=",
					Convert.ToString(gf.ShowDataDisplayMode + gf.ShowDataDisplaySlides * 2 + gf.ShowDataDisplaySongs * 4 + gf.ShowDataDisplayTitle * 8 + gf.ShowDataDisplayCopyright * 16 + gf.ShowDataDisplayPrevNext * 32),
					'>'
				});
				gf.WriteStringToBinaryFile(ref binaryWriter, inString);
				inString = string.Concat(new object[]
				{
					'\a',
					"=",
					gf.SystemID,
					":",
					'>'
				});
				gf.WriteStringToBinaryFile(ref binaryWriter, inString);
				inString = string.Concat(new object[]
				{
					'\b',
					"=",
					Convert.ToString(gf.ShowSongHeadings + gf.UseShadowFont * 2 + gf.ShowNotations * 4 + gf.ShowCapoZero * 8 + gf.ShowInterlace * 16 + gf.UseOutlineFont * 32),
					'>'
				});
				gf.WriteStringToBinaryFile(ref binaryWriter, inString);
				inString = string.Concat(new object[]
				{
					'\t',
					"=",
					Convert.ToString(gf.ShowLyrics),
					'>'
				});
				gf.WriteStringToBinaryFile(ref binaryWriter, inString);
				inString = string.Concat(new object[]
				{
					'\n',
					"=",
					Convert.ToString(gf.ShowScreenColour[0].ToArgb()),
					":",
					Convert.ToString(gf.ShowScreenColour[1].ToArgb()),
					":",
					gf.ShowScreenStyle.ToString(),
					'>'
				});
				gf.WriteStringToBinaryFile(ref binaryWriter, inString);
				inString = string.Concat(new object[]
				{
					'\f',
					"=",
					Convert.ToString(gf.ShowFontColour[0].ToArgb()),
					'>'
				});
				gf.WriteStringToBinaryFile(ref binaryWriter, inString);
				inString = string.Concat(new object[]
				{
					'\r',
					"=",
					Convert.ToString(gf.ShowFontColour[1].ToArgb()),
					'>'
				});
				gf.WriteStringToBinaryFile(ref binaryWriter, inString);
				inString = string.Concat(new object[]
				{
					'\u000e',
					"=",
					Convert.ToString(gf.ShowFontAlign[0, 0]),
					'>'
				});
				gf.WriteStringToBinaryFile(ref binaryWriter, inString);
				inString = string.Concat(new object[]
				{
					'\u000f',
					"=",
					Convert.ToString(gf.ShowFontAlign[0, 1]),
					'>'
				});
				gf.WriteStringToBinaryFile(ref binaryWriter, inString);
				inString = string.Concat(new object[]
				{
					'\u001a',
					"=",
					gf.BackgroundPicture,
					'>'
				});
				gf.WriteStringToBinaryFile(ref binaryWriter, inString);
				inString = string.Concat(new object[]
				{
					'\u001b',
					"=",
					Convert.ToString((int)gf.BackgroundMode),
					'>'
				});
				gf.WriteStringToBinaryFile(ref binaryWriter, inString);
				inString = string.Concat(new object[]
				{
					'\u001c',
					"=",
					Convert.ToString(gf.ShowVerticalAlign),
					'>'
				});
				gf.WriteStringToBinaryFile(ref binaryWriter, inString);
				inString = string.Concat(new object[]
				{
					'\u001d',
					"=",
					Convert.ToString(gf.ShowLeftMargin[0]),
					'>'
				});
				gf.WriteStringToBinaryFile(ref binaryWriter, inString);
				inString = string.Concat(new object[]
				{
					'\u001e',
					"=",
					Convert.ToString(gf.ShowRightMargin[0]),
					'>'
				});
				gf.WriteStringToBinaryFile(ref binaryWriter, inString);
				inString = string.Concat(new object[]
				{
					'\u001f',
					"=",
					Convert.ToString(gf.ShowBottomMargin[0]),
					'>'
				});
				gf.WriteStringToBinaryFile(ref binaryWriter, inString);
				inString = string.Concat(new object[]
				{
					'!',
					"=",
					gf.GlobalImageCanvas.GetTransitionText(gf.ShowItemTransition),
					'>'
				});
				gf.WriteStringToBinaryFile(ref binaryWriter, inString);
				inString = string.Concat(new object[]
				{
					'"',
					"=",
					gf.GlobalImageCanvas.GetTransitionText(gf.ShowSlideTransition),
					'>'
				});
				gf.WriteStringToBinaryFile(ref binaryWriter, inString);
				for (int i = 0; i <= 6; i++)
				{
					int num = 141 + i * 5;
					inString = string.Concat(new object[]
					{
						(char)num,
						"=",
						Convert.ToString(gf.PB_ShowWords[i] + gf.PB_WordsBold[i] * 2 + gf.PB_WordsItalic[i] * 4 + gf.PB_WordsUnderline[i] * 8),
						'>'
					});
					gf.WriteStringToBinaryFile(ref binaryWriter, inString);
					inString = string.Concat(new object[]
					{
						(char)(num + 1),
						"=",
						Convert.ToString(gf.PB_WordsSize[i]),
						'>'
					});
					gf.WriteStringToBinaryFile(ref binaryWriter, inString);
				}
				inString = string.Concat(new object[]
				{
					'µ',
					"=",
					Convert.ToString(gf.PB_ShowHeadings[0] + gf.PB_ShowHeadings[1] * 2 + gf.PB_ShowHeadings[2] * 4 + gf.PB_ShowHeadings[3] * 8),
					'>'
				});
				gf.WriteStringToBinaryFile(ref binaryWriter, inString);
				inString = string.Concat(new object[]
				{
					'¶',
					"=",
					Convert.ToString(gf.PB_LyricsPattern),
					'>'
				});
				gf.WriteStringToBinaryFile(ref binaryWriter, inString);
				inString = string.Concat(new object[]
				{
					'·',
					"=",
					Convert.ToString(gf.PB_ShowSection),
					'>'
				});
				gf.WriteStringToBinaryFile(ref binaryWriter, inString);
				inString = string.Concat(new object[]
				{
					'¸',
					"=",
					Convert.ToString(gf.PB_ShowColumns),
					'>'
				});
				gf.WriteStringToBinaryFile(ref binaryWriter, inString);
				inString = string.Concat(new object[]
				{
					'¹',
					"=",
					Convert.ToString(gf.PB_Spacing[0]),
					'>'
				});
				gf.WriteStringToBinaryFile(ref binaryWriter, inString);
				inString = string.Concat(new object[]
				{
					'º',
					"=",
					Convert.ToString(gf.PB_Spacing[1]),
					'>'
				});
				gf.WriteStringToBinaryFile(ref binaryWriter, inString);
				inString = string.Concat(new object[]
				{
					'»',
					"=",
					Convert.ToString(gf.PB_ShowScreenBreaks),
					'>'
				});
				gf.WriteStringToBinaryFile(ref binaryWriter, inString);
				inString = string.Concat(new object[]
				{
					'Ã',
					"=",
					Convert.ToString(gf.PB_CJKGroupStyle),
					'>'
				});
				gf.WriteStringToBinaryFile(ref binaryWriter, inString);
				inString = string.Concat(new object[]
				{
					'Ä',
					"=",
					Convert.ToString(gf.PB_ShowNotations + gf.PB_ShowTiming * 2 + gf.PB_ShowKey * 4 + gf.PB_ShowCapo * 8 + gf.PB_CapoZero * 16),
					'>'
				});
				gf.WriteStringToBinaryFile(ref binaryWriter, inString);
				inString = "]";
				gf.WriteStringToBinaryFile(ref binaryWriter, inString);
				string text = "";
				for (int i = 1; i <= InList.Items.Count; i++)
				{
					string text2;
					string text3;
					if (InMode == gf.UsageMode.Worship)
					{
						text2 = gf.Trim(InList.Items[i - 1].SubItems[1].Text);
						string a = gf.Left(text2, 1);
						if (a == "D")
						{
							text = gf.RemoveMusicSym(gf.Trim(InList.Items[i - 1].Text));
							if (gf.Right(text, " <Error - Item Not Found>".Length) == " <Error - Item Not Found>")
							{
								text = gf.Left(text, text.Length - " <Error - Item Not Found>".Length);
							}
							text += ((InList.Items[i - 1].SubItems[7].Text == "") ? "" : (":" + InList.Items[i - 1].SubItems[7].Text));
						}
						else
						{
							if (a == "P")
							{
								text = gf.Mid(text2, 1);
								text2 = "P1";
							}
							else
							{
								if (a == "B")
								{
									text = gf.Trim(InList.Items[i - 1].Text);
									text2 = "B" + gf.Mid(text2, 1);
								}
								else
								{
									if (a == "T")
									{
										text = gf.Mid(text2, 1);
										text2 = "T1";
									}
									else
									{
										if (a == "I")
										{
											text = gf.Mid(text2, 1);
											text2 = "I1";
										}
										else
										{
											if (a == "W")
											{
												text = gf.Mid(text2, 1);
												text2 = "W1";
											}
											else
											{
												if (a == "M")
												{
													text = gf.Mid(text2, 1);
													text2 = "M1";
												}
											}
										}
									}
								}
							}
						}
						text3 = gf.Trim(InList.Items[i - 1].SubItems[2].Text);
					}
					else
					{
						text2 = gf.Trim(InList.Items[i - 1].SubItems[3].Text);
						text = gf.RemoveMusicSym(gf.Trim(InList.Items[i - 1].SubItems[2].Text));
						text3 = InList.Items[i - 1].SubItems[5].Text;
					}
					inString = string.Concat(new object[]
					{
						text2,
						"\\",
						text,
						"\\",
						'*',
						text3,
						'>'
					});
					gf.WriteStringToBinaryFile(ref binaryWriter, inString);
				}
				binaryWriter.Close();
				fileStream.Close();
			}
			catch
			{
			}
		}
		public static void WriteStringToBinaryFile(ref BinaryWriter w, string InString)
		{
			w.Write(Encoding.Unicode.GetBytes(InString));
		}
		public static void ReMapKeyBoard(ref Keys InKey)
		{
			if (InKey == Keys.Home)
			{
				if (gf.KeyBoardOption == 1)
				{
					InKey = Keys.Left;
				}
			}
			else
			{
				if (InKey == Keys.Prior)
				{
					if (gf.KeyBoardOption == 1)
					{
						InKey = Keys.Up;
					}
				}
				else
				{
					if (InKey == Keys.Next)
					{
						if (gf.KeyBoardOption == 1)
						{
							InKey = Keys.Down;
						}
					}
					else
					{
						if (InKey == Keys.End)
						{
							if (gf.KeyBoardOption == 1)
							{
								InKey = Keys.Right;
							}
						}
						else
						{
							if (InKey == Keys.Left)
							{
								if (gf.KeyBoardOption == 1)
								{
									InKey = Keys.Home;
								}
							}
							else
							{
								if (InKey == Keys.Up)
								{
									if (gf.KeyBoardOption == 1)
									{
										InKey = Keys.Prior;
									}
								}
								else
								{
									if (InKey == Keys.Down)
									{
										if (gf.KeyBoardOption == 1)
										{
											InKey = Keys.Next;
										}
									}
									else
									{
										if (InKey == Keys.Right)
										{
											if (gf.KeyBoardOption == 1)
											{
												InKey = Keys.End;
											}
										}
									}
								}
							}
						}
					}
				}
			}
		}
		public static int ImplementSlideMovement(ref int InCurSlide, int InCurMaxSlide, Keys InKey, int InSlideNo)
		{
			if (InKey == Keys.Left)
			{
				InCurSlide = 1;
			}
			else
			{
				if (InKey == Keys.Up)
				{
					InCurSlide = ((InCurSlide > 2) ? (InCurSlide - 1) : 1);
				}
				else
				{
					if (InKey == Keys.Down)
					{
						InCurSlide = ((InCurSlide < InCurMaxSlide) ? (InCurSlide + 1) : InCurMaxSlide);
					}
					else
					{
						if (InKey == Keys.Right)
						{
							InCurSlide = InCurMaxSlide;
						}
						else
						{
							if (InKey == Keys.None)
							{
								InCurSlide = InSlideNo;
							}
							else
							{
								if (InKey == Keys.F5)
								{
								}
							}
						}
					}
				}
			}
			return InCurSlide;
		}
		public static Keys ReMapKeyDirectionToPowerpoint(gf.KeyDirection InDirection)
		{
			Keys result;
			switch (InDirection)
			{
			case gf.KeyDirection.FirstOne:
				result = Keys.Left;
				break;
			case gf.KeyDirection.PrevOne:
				result = Keys.Up;
				break;
			case gf.KeyDirection.NextOne:
				result = Keys.Down;
				break;
			case gf.KeyDirection.LastOne:
				result = Keys.Right;
				break;
			default:
				result = Keys.F5;
				break;
			}
			return result;
		}
		public static string LoadTextFile(string InFileName)
		{
			return gf.LoadTextFile(InFileName, false);
		}
		public static string LoadTextFile(string InFileName, bool ShowErrorMsg)
		{
			string result;
			try
			{
				StreamReader streamReader = new StreamReader(InFileName, Encoding.GetEncoding(1252));
				string text = streamReader.ReadToEnd();
				streamReader.Close();
				result = text.Replace("\r\n", "\n").Replace("\v", "\n");
			}
			catch
			{
				if (ShowErrorMsg)
				{
					MessageBox.Show("Cannot open the selected text file. The text file might be corrupted");
				}
				result = "";
			}
			return result;
		}
		public static void Load32InfoFile(string InFileName, ref gf.SongSettings InItem, ref string[] ThisHeaderData)
		{
			try
			{
				StreamReader streamReader = File.OpenText(InFileName);
				string text = streamReader.ReadToEnd();
				streamReader.Close();
				string inString = "";
				string title = "";
				string rotateString = "";
				int num = text.IndexOf("[");
				int num2 = text.IndexOf("]", num + 1);
				if (num == 0 & num2 > 1)
				{
					num++;
					string text2 = gf.Mid(text, num, num2 - num);
					if (gf.Convertv32FormatString(ref text2, '*', ref title, ref inString, ref rotateString) == 320)
					{
						InItem.CompleteLyrics = gf.Mid(text, num2 + 1, text.Length - num2);
						InItem.Title = title;
						InItem.FolderNo = gf.StringToInt(inString);
						if (InItem.FolderNo < 1)
						{
							InItem.FolderNo = 1;
						}
						InItem.RotateString = rotateString;
					}
				}
			}
			catch
			{
			}
		}
		public static void LoadInfoFile(string InFileName, ref gf.SongSettings InItem, ref string[] ThisHeaderData)
		{
			try
			{
				XmlTextReader xmlTextReader = new XmlTextReader(InFileName);
				try
				{
					bool flag = gf.ValidateEasiSlidesXML(ref xmlTextReader);
					if (flag)
					{
						string itemID = InItem.ItemID;
						gf.ExtractEasiSlidesXMLItem(ref xmlTextReader, ref InItem);
						InItem.ItemID = itemID;
					}
					else
					{
						gf.Load32InfoFile(InFileName, ref InItem, ref ThisHeaderData);
					}
				}
				catch
				{
				}
				if (xmlTextReader != null)
				{
					xmlTextReader.Close();
				}
			}
			catch
			{
			}
		}
		public static bool ValidateEasiSlidesXML(ref XmlTextReader reader)
		{
			bool result;
			try
			{
				reader.Read();
				while (reader.Read())
				{
					if (reader.NodeType == XmlNodeType.Element & reader.Name == "EasiSlides")
					{
						result = true;
						return result;
					}
				}
			}
			catch
			{
			}
			result = false;
			return result;
		}
		public static bool MoveToXMLItemElement(ref XmlTextReader reader)
		{
			bool result;
			while (reader.Read())
			{
				if (reader.NodeType == XmlNodeType.Element & reader.Name == "Item")
				{
					result = true;
					return result;
				}
			}
			result = false;
			return result;
		}
		public static bool ExtractEasiSlidesXMLItem(ref XmlTextReader reader, ref gf.SongSettings InItem)
		{
			bool flag = false;
			InItem.Type = "I";
			bool result;
			if (gf.MoveToXMLItemElement(ref reader))
			{
				while (reader.Read())
				{
					XmlNodeType nodeType = reader.NodeType;
					if (nodeType != XmlNodeType.Element)
					{
						if (nodeType == XmlNodeType.EndElement)
						{
							string name = reader.Name;
							if (reader.Name == "Item")
							{
								InItem.In_LicAdminInfo1 = InItem.Show_LicAdminInfo1;
								InItem.In_LicAdminInfo2 = InItem.Show_LicAdminInfo2;
								gf.LoadLicAdminDisplayInfo(ref InItem.Show_LicAdminInfo1, ref InItem.Show_LicAdminInfo2);
								result = flag;
								return result;
							}
						}
					}
					else
					{
						string name = reader.Name;
						string elementValue = reader.ReadElementContentAsObject().ToString();
						gf.AssignElementToItem(ref InItem, name, elementValue);
						flag = true;
					}
				}
			}
			result = false;
			return result;
		}
		public static void GetTitle2AndFormatFromInfoFile(string InFileName, ref string Title2, ref string FormatString)
		{
			gf.InitialiseIndividualData(ref gf.TempItem1);
			gf.LoadInfoFile(InFileName, ref gf.TempItem1, ref gf.tempHeaderData);
			Title2 = gf.TempItem1.Title2;
			FormatString = gf.TempItem1.Format.FormatString;
		}
		public static void AssignElementToItem(ref gf.SongSettings InItem, string ElementName, string ElementValue)
		{
			switch (ElementName)
			{
			case "Title1":
				InItem.Title = ElementValue;
				break;
			case "Title2":
				InItem.Title2 = ElementValue;
				break;
			case "Folder":
				InItem.FolderName = ElementValue;
				InItem.FolderNo = gf.GetFolderNumber(ElementValue);
				break;
			case "SongNumber":
				InItem.SongNumber = gf.StringToInt(ElementValue);
				break;
			case "Contents":
				InItem.CompleteLyrics = ElementValue;
				break;
			case "Notations":
				InItem.Notations = ElementValue;
				break;
			case "Sequence":
				InItem.SongSequence = gf.ConvertTextStringToSequence(ElementValue);
				InItem.SongOriginalLoadedSequence = InItem.SongSequence;
				break;
			case "Writer":
				InItem.Writer = ElementValue;
				break;
			case "Copyright":
				InItem.Copyright = ElementValue;
				break;
			case "Category":
				InItem.Category = ElementValue;
				break;
			case "Timing":
				InItem.Timing = ElementValue;
				break;
			case "MusicKey":
				InItem.MusicKey = ElementValue;
				break;
			case "Capo":
				InItem.Capo = gf.StringToInt(ElementValue, true);
				break;
			case "LicenceAdmin1":
				InItem.Show_LicAdminInfo1 = ElementValue;
				break;
			case "LicenceAdmin2":
				InItem.Show_LicAdminInfo2 = ElementValue;
				break;
			case "BookReference":
				InItem.Book_Reference = ElementValue;
				break;
			case "UserReference":
				InItem.User_Reference = ElementValue;
				break;
			case "FormatData":
				InItem.Format.FormatString = ElementValue;
				break;
			case "Settings":
				InItem.Settings = ElementValue;
				InItem.RotateString = gf.ExtractSettings(ElementValue, gf.SettingsCategory.RotateString);
				gf.GetRotationStyle(ref InItem);
				break;
			case "Image":
				InItem.Format.ImageString = ElementValue;
				break;
			}
		}
		public static string ExtractSettings(string InSettingsString, gf.SettingsCategory settingsCategory)
		{
			string result;
			if (InSettingsString == "")
			{
				result = "";
			}
			else
			{
				string[] array = InSettingsString.Split(new char[]
				{
					'>'
				});
				for (int i = 0; i <= array.GetUpperBound(0); i++)
				{
					string text = gf.ExtractOneInfo(ref array[i], '=', true, false);
					if (text != "")
					{
						int num = gf.StringToInt(text);
						if (num == (int)settingsCategory)
						{
							result = array[i];
							return result;
						}
					}
				}
				result = "";
			}
			return result;
		}
		public static string CombineSettings(gf.SongSettings InItem)
		{
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.Append(string.Concat(new object[]
			{
				Convert.ToString(10),
				"=",
				InItem.RotateString,
				'>'
			}));
			return stringBuilder.ToString();
		}
		public static string dumpImageToFile(byte[] img, string InFileName)
		{
			string result;
			try
			{
				string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(InFileName);
				string extension = Path.GetExtension(InFileName);
				string text = gf.EasiSlidesTempDir + fileNameWithoutExtension + gf.GetUniqueID() + extension;
				FileStream fileStream = new FileStream(text, FileMode.OpenOrCreate, FileAccess.Write);
				int num = 0;
				fileStream.Write(img, num, img.Length - num);
				fileStream.Close();
				result = text;
			}
			catch
			{
				result = "";
			}
			return result;
		}
		public static void StartElement(object strURI, string strName, string strName_3, object attributes)
		{
			throw new Exception("The method or operation is not implemented.");
		}
		public static void OldSaveInfoFile(string InFullFileName, string InText, string[] ThisHeaderData)
		{
			try
			{
				FileStream fileStream = new FileStream(InFullFileName, FileMode.Create);
				BinaryWriter binaryWriter = new BinaryWriter(fileStream);
				binaryWriter.Write(255);
				binaryWriter.Write(254);
				string inString = "[";
				gf.WriteStringToBinaryFile(ref binaryWriter, inString);
				inString = string.Concat(new object[]
				{
					'\u0001',
					"=",
					320.ToString(),
					'*'.ToString()
				});
				gf.WriteStringToBinaryFile(ref binaryWriter, inString);
				for (int i = 2; i <= 254; i++)
				{
					if (ThisHeaderData[i] != "" && ThisHeaderData[i] != null)
					{
						inString = string.Concat(new object[]
						{
							(char)i,
							"=",
							ThisHeaderData[i],
							'*'.ToString()
						});
						gf.WriteStringToBinaryFile(ref binaryWriter, inString);
					}
				}
				inString = "]";
				gf.WriteStringToBinaryFile(ref binaryWriter, inString);
				gf.WriteStringToBinaryFile(ref binaryWriter, InText);
				binaryWriter.Close();
				fileStream.Close();
			}
			catch
			{
			}
		}
		public static string SetPowerpointPreviewPrefix(gf.SongSettings InItem)
		{
			string result;
			if (InItem.Type != "P")
			{
				result = "";
			}
			else
			{
				if (InItem.OutputStyleScreen)
				{
					if (gf.OUTPPSequence < 0 | gf.OUTPPSequence >= 49)
					{
						gf.OUTPPSequence = 0;
					}
					gf.OUTPPSequence++;
					gf.OUTPPFullPath = gf.OUTPPPrefix + gf.OUTPPSequence.ToString();
					result = gf.OUTPPFullPath;
				}
				else
				{
					if (gf.PREPPSequence < 0 | gf.PREPPSequence >= 49)
					{
						gf.PREPPSequence = 0;
					}
					gf.PREPPSequence++;
					gf.PREPPFullPath = gf.PREPPPrefix + gf.PREPPSequence.ToString();
					result = gf.PREPPFullPath;
				}
			}
			return result;
		}
		public static void MinimizePowerPointWindows(ref PP InPPT)
		{
			InPPT.ResSetAllShowWindows();
		}
		public static int RunPowerpointSong(ref gf.SongSettings InItem, ref PP InPPT, int StartingSlide)
		{
			return gf.RunPowerpointSong(ref InItem, ref InPPT, StartingSlide, false);
		}
		public static int RunPowerpointSong(ref gf.SongSettings InItem, ref PP InPPT, int StartingSlide, bool ShowResult)
		{
			for (int i = 1; i <= 1000; i++)
			{
				InItem.Slide[i, 0] = -1;
			}
			for (int i = 0; i <= 9; i++)
			{
				InItem.SongVerses[i] = 0;
			}
			string text = InPPT.Run(InItem.Path, ref gf.PowerpointList, ref gf.TotalPowerpointItems);
			if (StartingSlide < 2)
			{
				InPPT.First();
				InItem.CurSlide = 1;
			}
			else
			{
				if (StartingSlide > InPPT.Count())
				{
					InPPT.Last();
					InItem.CurSlide = InPPT.Count();
				}
				else
				{
					if (InPPT.Count() > 0)
					{
						InPPT.GotoSlide(StartingSlide);
						InItem.CurSlide = StartingSlide;
					}
				}
			}
			if (!gf.ShowLiveCam)
			{
				if (gf.DualMonitorMode)
				{
					InPPT.SetShowWindow((float)gf.LS_Left * 0.75f, (float)gf.LS_Top * 0.75f, (float)gf.LS_Width * 0.75f, (float)gf.LS_Height * 0.75f);
				}
				else
				{
					InPPT.SetShowWindow((float)gf.LS_Left, (float)gf.LS_Top, (float)gf.LS_Width * 0.75f, (float)gf.LS_Height * 0.75f);
				}
			}
			InPPT.LoadVersesAndSlides(ref InItem.SongVerses, ref InItem.Slide, gf.SequenceSymbol);
			return InPPT.Count();
		}
		public static string GetOfficeDocContents(string InFileName)
		{
			string result;
			try
			{
				WordDoc wordDoc = new WordDoc();
				result = wordDoc.GetContents(InFileName).Replace("\v", "\n");
				return result;
			}
			catch (Exception var_1_21)
			{
			}
			result = "";
			return result;
		}
		public static bool SupportedImageFormat(string InFileName)
		{
			string a = gf.Right(InFileName, 4).ToLower();
			return a == ".bmp" | a == ".jpg" | a == ".ico" | a == ".gif" | gf.Right(InFileName, 5).ToLower() == ".jpeg";
		}
		public static bool SupportedOpenDocFormat(string InFileName)
		{
			string a = gf.Right(InFileName, 4).ToLower();
			return a == ".doc" | a == ".txt";
		}
		public static int ValidateSongMovement(ref int InCurItem, int InCurMaxItems, Keys InKey, int InItemNo)
		{
			if (InKey == Keys.Home)
			{
				InCurItem = 1;
			}
			else
			{
				if (InKey == Keys.End)
				{
					InCurItem = InCurMaxItems;
				}
				else
				{
					if (InKey == Keys.Prior)
					{
						InCurItem = ((InCurItem > 2) ? (InCurItem - 1) : 1);
					}
					else
					{
						if (InKey == Keys.Next)
						{
							InCurItem = ((InCurItem < InCurMaxItems) ? (InCurItem + 1) : InCurMaxItems);
						}
						else
						{
							if (InKey == Keys.None)
							{
								InCurItem = ((InItemNo > 0) ? ((InItemNo <= InCurMaxItems) ? InItemNo : InCurMaxItems) : InCurItem);
							}
						}
					}
				}
			}
			return InCurItem;
		}
		public static void SetTransparentBackground(gf.SongSettings InItem, ref ImageTransitionControl InPic)
		{
			gf.SetColoursFormat(InItem, ref InPic, true);
		}
		public static void OldSwitchChineseLyricsNotationListView(ref ListView InLyricsAndNotationsList, int ChangeTo)
		{
			if (InLyricsAndNotationsList.Items.Count > 0)
			{
				for (int i = 0; i <= InLyricsAndNotationsList.Items.Count - 1; i++)
				{
					string text = InLyricsAndNotationsList.Items[i].SubItems[2].Text;
					gf.SwitchChinese(ref text, ChangeTo);
					InLyricsAndNotationsList.Items[i].SubItems[2].Text = text;
				}
			}
		}
		public static void SwitchChineseLyricsNotationListView(ref gf.SongSettings InItem, int ChangeTo)
		{
			if (InItem.LyricsAndNotationsList.Items.Count > 0)
			{
				for (int i = 0; i <= InItem.LyricsAndNotationsList.Items.Count - 1; i++)
				{
					string text = InItem.LyricsAndNotationsList.Items[i].SubItems[2].Text;
					gf.SwitchChinese(ref text, ChangeTo);
					InItem.LyricsAndNotationsList.Items[i].SubItems[2].Text = text;
					gf.SwitchChinese(ref InItem.Title, ChangeTo);
					gf.SwitchChinese(ref InItem.Title2, ChangeTo);
					gf.SwitchChinese(ref InItem.Copyright, ChangeTo);
				}
			}
		}
		public static int SwitchChinese(ref RichTextBox InTextBox)
		{
			string text = InTextBox.Text;
			int num = gf.SwitchChinese(ref text);
			string[] array = text.Split(new char[]
			{
				"\n"[0]
			});
			int num2 = 0;
			gf.SendMessage(InTextBox.Handle, 11u, 0u, 0u);
			for (int i = 0; i <= array.GetUpperBound(0); i++)
			{
				int num3 = text.IndexOf("\n"[0], num2);
				gf.SwitchChinese(ref array[i], num);
				string selectedText = array[i];
				int selectionLength = num3 - num2;
				if (num3 >= 0)
				{
					InTextBox.SelectionStart = num2;
					InTextBox.SelectionLength = selectionLength;
					InTextBox.SelectedText = selectedText;
					num2 = num3 + 1;
				}
				else
				{
					if (num2 <= text.Length)
					{
						InTextBox.SelectionStart = num2;
						InTextBox.SelectionLength = text.Length - num2;
						InTextBox.SelectedText = selectedText;
					}
				}
			}
			gf.SendMessage(InTextBox.Handle, 11u, 1u, 0u);
			return num;
		}
		public static int SwitchChinese(ref string InString)
		{
			return gf.SwitchChinese(ref InString, -1);
		}
		public static int SwitchChinese(ref string InString, int SelectedType)
		{
			string text = "»#«";
			char c = '祢';
			string text2 = InString;
			text2 = Strings.StrConv(text2, VbStrConv.SimplifiedChinese, CultureInfo.CurrentCulture.LCID);
			int result;
			if (SelectedType == 1)
			{
				if (!(text2 == InString))
				{
					InString = text2;
				}
				result = 1;
			}
			else
			{
				if (SelectedType == 0)
				{
					if (text2 == InString)
					{
						text2 = text2.Replace(c.ToString(), text);
						text2 = Strings.StrConv(text2, VbStrConv.TraditionalChinese, CultureInfo.CurrentCulture.LCID);
						text2 = text2.Replace(text, c.ToString());
						InString = text2;
					}
					result = 0;
				}
				else
				{
					if (text2 == InString)
					{
						text2 = text2.Replace(c.ToString(), text);
						text2 = Strings.StrConv(text2, VbStrConv.TraditionalChinese, CultureInfo.CurrentCulture.LCID);
						text2 = text2.Replace(text, c.ToString());
						InString = text2;
						result = 0;
					}
					else
					{
						InString = text2;
						result = 1;
					}
				}
			}
			return result;
		}
		public static string ExtractFolderFromListTitle(ref string InListTitle)
		{
			string result = "1";
			int num = InListTitle.IndexOf(":", 0);
			if (num > 0)
			{
				string inName = gf.Trim(gf.Right(InListTitle, InListTitle.Length - num - 1));
				result = gf.GetFolderNumber(inName, true).ToString();
				InListTitle = gf.Left(InListTitle, num);
			}
			return result;
		}
		public static void PreLoadPowerpointFiles(ref PP InPP, ref string[,] InSongsArray)
		{
			bool flag = false;
			for (int i = 0; i <= gf.TotalWorshipListItems; i++)
			{
				try
				{
					if (InSongsArray[i, 1] == "P")
					{
						if (!flag)
						{
							InPP.NewApp();
							flag = true;
						}
						InPP.Open(gf.Right(InSongsArray[i, 0], InSongsArray[i, 0].Length - 1), ref gf.PowerpointList, ref gf.TotalPowerpointItems);
					}
				}
				catch
				{
				}
			}
		}
		public static void ClearUpPowerpointWindows()
		{
			string text = gf.LivePP.ClearUpPowerpointWindows(ref gf.PowerpointList, ref gf.TotalPowerpointItems);
		}
		public static bool PowerpointPresent()
		{
			string text = Application.StartupPath + "\\Sys\\~temp.ppt";
			gf.MakeDir(Application.StartupPath + "\\Sys");
			if (!File.Exists(text))
			{
				gf.CreateNewFile(text);
			}
			text = '"' + text + '"';
			string lpResult = new string(' ', 260);
			return gf.FindExecutable(text, "", lpResult) > 32;
		}
		public static void SetDefaultBackScreen(ref ImageTransitionControl InScreen)
		{
			Image image = new Bitmap(gf.Buffer_LS_Width, gf.Buffer_LS_Height);
			Graphics graphics = Graphics.FromImage(image);
			gf.BackPattern.Fill(ref graphics, gf.ShowScreenColour[0], gf.ShowScreenColour[1], gf.ShowScreenStyle, gf.Buffer_LS_Width, gf.Buffer_LS_Height, ref gf.DefaultBackgroundID);
			InScreen.SetDefaultBackgroundPicture(image);
		}
		public static bool EmptyDelFolder()
		{
			bool result;
			try
			{
				OleDbConnection oleDbConnection = new OleDbConnection(gf.ConnectStringMainDB);
				OleDbCommand oleDbCommand = new OleDbCommand("Delete * from Song where FolderNo =0", oleDbConnection);
				oleDbConnection.Open();
				oleDbCommand.ExecuteNonQuery();
				oleDbConnection.Close();
				result = true;
				return result;
			}
			catch
			{
			}
			result = false;
			return result;
		}
		public static int ReFileSelectedSongs(ref ListView InListView, int CurFolder, int NewFolder, ref int[] RefileSongs, bool UpdateModifiedDate)
		{
			RefileSongs[0] = 0;
			try
			{
				Recordset recordset = gf.GetTableRecordSet(gf.ConnectStringMainDB, "SONG");
				recordset.Index = "PrimaryKey";
				for (int i = InListView.Items.Count - 1; i >= 0; i--)
				{
					if (InListView.Items[i].Selected)
					{
						string text;
						if (CurFolder == 0)
						{
							text = InListView.Items[i].SubItems[3].Text;
							NewFolder = gf.StringToInt(InListView.Items[i].SubItems[1].Text);
						}
						else
						{
							string text2 = InListView.Items[i].SubItems[1].Text;
							text = gf.Right(text2, text2.Length - 1);
						}
						try
						{
							recordset.Seek("=", text, gf.def, gf.def, gf.def, gf.def, gf.def, gf.def, gf.def, gf.def, gf.def, gf.def, gf.def, gf.def);
							if (!recordset.NoMatch)
							{
								recordset.Edit();
								recordset.Fields["OldFolder"].Value = CurFolder;
								recordset.Fields["FolderNo"].Value = NewFolder;
								if (UpdateModifiedDate)
								{
									recordset.Fields["LastModified"].Value = DateTime.Now.Date;
								}
								recordset.Update(1, false);
								InListView.Items[i].Remove();
								RefileSongs[0]++;
								RefileSongs[RefileSongs[0]] = gf.StringToInt(text);
							}
						}
						catch
						{
						}
					}
				}
				if (recordset != null)
				{
					recordset.Close();
					recordset = null;
				}
			}
			catch
			{
			}
			return RefileSongs[0];
		}
		public static int ReFileSelectedSongs(ref ListView InListView)
		{
			try
			{
				Recordset recordset = gf.GetTableRecordSet(gf.ConnectStringMainDB, "SONG");
				recordset.Index = "PrimaryKey";
				for (int i = InListView.Items.Count - 1; i >= 0; i--)
				{
					if (InListView.Items[i].Checked)
					{
						string text = InListView.Items[i].SubItems[3].Text;
						try
						{
							recordset.Seek("=", text, gf.def, gf.def, gf.def, gf.def, gf.def, gf.def, gf.def, gf.def, gf.def, gf.def, gf.def, gf.def);
							if (!recordset.NoMatch)
							{
								int num = Convert.ToInt32(InListView.Items[i].SubItems[4].Text);
								recordset.Edit();
								recordset.Fields["OldFolder"].Value = 0;
								recordset.Fields["FolderNo"].Value = num;
								recordset.Fields["LastModified"].Value = DateTime.Now.Date;
								recordset.Update(1, false);
								InListView.Items[i].Remove();
							}
						}
						catch
						{
						}
					}
				}
				if (recordset != null)
				{
					recordset.Close();
					recordset = null;
				}
			}
			catch
			{
			}
			return InListView.CheckedItems.Count;
		}
		public static int ReFileSelectedSongsADO(ref ListView.SelectedListViewItemCollection SongItems, int CurFolder, int NewFolder, ref int[] RefileSongs, bool UpdateModifiedDate)
		{
			RefileSongs[0] = 0;
			try
			{
				OleDbConnection oleDbConnection = new OleDbConnection(gf.ConnectStringMainDB);
				oleDbConnection.Open();
				for (int i = SongItems.Count - 1; i >= 0; i--)
				{
					try
					{
						string text;
						if (CurFolder == 0)
						{
							text = SongItems[i].SubItems[3].Text;
							NewFolder = gf.StringToInt(SongItems[i].SubItems[1].Text);
						}
						else
						{
							string text2 = SongItems[i].SubItems[1].Text;
							text = gf.Right(text2, text2.Length - 1);
						}
						string text3 = "Update SONG SET OldFolder = @OldFolder, FolderNo =@FolderNo" + (UpdateModifiedDate ? ", LastModified =@LastModified" : "") + " where songid=" + text.ToString();
						OleDbCommand oleDbCommand = new OleDbCommand(text3, oleDbConnection);
						oleDbCommand.CommandText = text3;
						oleDbCommand.Parameters.AddWithValue("@OldFolder", CurFolder);
						oleDbCommand.Parameters.AddWithValue("@FolderNo", NewFolder);
						oleDbCommand.Parameters.AddWithValue("@LastModified", DateTime.Now.Date);
						oleDbCommand.ExecuteNonQuery();
						oleDbCommand.Dispose();
						SongItems[i].Remove();
						RefileSongs[0]++;
						RefileSongs[RefileSongs[0]] = gf.StringToInt(text);
					}
					catch (Exception var_6_178)
					{
					}
				}
				oleDbConnection.Close();
			}
			catch
			{
			}
			return RefileSongs[0];
		}
		public static int ReFileSelectedSongsADO(ref ListView.CheckedListViewItemCollection SongItems)
		{
			try
			{
				OleDbConnection oleDbConnection = new OleDbConnection(gf.ConnectStringMainDB);
				oleDbConnection.Open();
				for (int i = SongItems.Count - 1; i >= 0; i--)
				{
					try
					{
						string text = SongItems[i].SubItems[3].Text;
						int folderNumber = gf.GetFolderNumber(SongItems[i].SubItems[1].Text);
						string text2 = "Update SONG SET OldFolder = @OldFolder,FolderNo =@FolderNo,LastModified =@LastModified where songid=" + text.ToString();
						OleDbCommand oleDbCommand = new OleDbCommand(text2, oleDbConnection);
						oleDbCommand.CommandText = text2;
						oleDbCommand.Parameters.AddWithValue("@OldFolder", 0);
						oleDbCommand.Parameters.AddWithValue("@FolderNo", folderNumber);
						oleDbCommand.Parameters.AddWithValue("@LastModified", DateTime.Now.Date);
						oleDbCommand.ExecuteNonQuery();
						SongItems[i].Remove();
					}
					catch (Exception var_7_FB)
					{
					}
				}
				oleDbConnection.Close();
			}
			catch
			{
			}
			return SongItems.Count;
		}
		public static void CompactAllDB()
		{
			if (MessageBox.Show("This will compact and repair the EasiSlides Databases. Click Yes to proceed.", "Compact EasiSlides Databases", MessageBoxButtons.YesNo) == DialogResult.Yes)
			{
				bool flag = gf.CompactOneDB(gf.DBFileName, gf.tempDBFileName);
				bool flag2 = gf.CompactOneDB(gf.UsageFileName, gf.tempUsageFileName);
				bool flag3 = gf.CompactOneDB(gf.BiblesListFileName, gf.tempBiblesListFileName);
				if (flag & flag2 & flag3)
				{
					MessageBox.Show("EasiSlides Databases compacted successfully.");
				}
				else
				{
					MessageBox.Show("Error - Cannot Compact one or more Databases because they are locked. Please restart EasiSlides and try again.");
				}
			}
		}
		public static bool CompactOneDB(string InDatabaseFilename, string InTempDatabaseFilename)
		{
			bool result;
			try
			{
				JetEngine jetEngine = new JetEngineClass();
				if (File.Exists(InTempDatabaseFilename))
				{
					File.Delete(InTempDatabaseFilename);
				}
				jetEngine.CompactDatabase("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + InDatabaseFilename, "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + InTempDatabaseFilename + ";Jet OLEDB:Engine Type=5");
				File.Delete(InDatabaseFilename);
				File.Move(InTempDatabaseFilename, InDatabaseFilename);
				result = true;
				return result;
			}
			catch
			{
			}
			result = false;
			return result;
		}
		public static bool ClearAllFormatting()
		{
			bool result;
			if (MessageBox.Show("This will clear all individual formatting held in the Lyrics Database. Click Yes to proceed.", "Compact EasiSlides Databases", MessageBoxButtons.YesNo) == DialogResult.Yes)
			{
				try
				{
					string fullSearchString = "select * from SONG where FORMATDATA <> ''";
					Database daoDb = gf.GetDaoDb(gf.ConnectStringMainDB);
					Recordset recordSet = gf.GetRecordSet(daoDb, fullSearchString);
					if (recordSet != null && !recordSet.EOF)
					{
						recordSet.MoveFirst();
						while (!recordSet.EOF)
						{
							recordSet.Edit();
							recordSet.Fields["FORMATDATA"].Value = "";
							recordSet.Update(1, false);
							recordSet.MoveNext();
						}
						recordSet.Close();
					}
					if (recordSet != null)
					{
					}
					result = true;
					return result;
				}
				catch
				{
				}
			}
			result = false;
			return result;
		}
		public static bool ClearRegistrySettings()
		{
			bool result;
			if (MessageBox.Show("Warning: This will clear all EasiSlides Registry Settings and EasiSlides will then Close. Please note that the next time you restart EasiSlides, the EasiSlides Working Folder will be set to C:\\EasiSlides. Click Yes if you wish to proceed.", "Clear EasiSlides Registry Settings", MessageBoxButtons.YesNo) == DialogResult.Yes)
			{
				try
				{
					RegistryKey registryKey = Registry.CurrentUser.OpenSubKey("Software", true);
					registryKey.DeleteSubKeyTree("EasiSlides");
					registryKey.Close();
					result = true;
					return result;
				}
				catch
				{
				}
			}
			result = false;
			return result;
		}
		public static bool SwapFolderNumbers(ListView InFolderOrder)
		{
			bool result;
			try
			{
				int[] array = new int[41];
				int num = 1;
				while (num < 41 && InFolderOrder.Items.Count < 41)
				{
					array[gf.GetFolderNumber(InFolderOrder.Items[num - 1].SubItems[0].Text)] = num;
					num++;
				}
				string fullSearchString = "select * from SONG WHERE FolderNo > 0 ";
				Database daoDb = gf.GetDaoDb(gf.ConnectStringMainDB);
				Recordset recordSet = gf.GetRecordSet(daoDb, fullSearchString);
				if (recordSet != null && !recordSet.EOF)
				{
					recordSet.MoveFirst();
					while (!recordSet.EOF)
					{
						int num2 = gf.ObjToInt(recordSet.Fields["FolderNo"].Value);
						if (num2 != array[num2])
						{
							recordSet.Edit();
							recordSet.Fields["FolderNo"].Value = array[num2];
							recordSet.Update(1, false);
						}
						recordSet.MoveNext();
					}
					recordSet.Close();
				}
				fullSearchString = "select * from FOLDER  where FolderNo > 0 ORDER BY FolderNo";
				recordSet = gf.GetRecordSet(daoDb, fullSearchString);
				if (recordSet != null && !recordSet.EOF)
				{
					recordSet.MoveFirst();
					while (!recordSet.EOF)
					{
						int num2 = gf.ObjToInt(recordSet.Fields["FolderNo"].Value);
						string text = gf.ObjToString(recordSet.Fields["Name"].Value);
						recordSet.Edit();
						recordSet.Fields["FolderNo"].Value = -array[num2];
						recordSet.Update(1, false);
						recordSet.MoveNext();
					}
					recordSet.Close();
				}
				if (recordSet != null)
				{
				}
				fullSearchString = "select * from FOLDER  where FolderNo < 0 ORDER BY FolderNo";
				recordSet = gf.GetRecordSet(daoDb, fullSearchString);
				if (recordSet != null && !recordSet.EOF)
				{
					recordSet.MoveFirst();
					while (!recordSet.EOF)
					{
						int num2 = gf.ObjToInt(recordSet.Fields["FolderNo"].Value);
						recordSet.Edit();
						recordSet.Fields["FolderNo"].Value = -num2;
						recordSet.Update(1, false);
						recordSet.MoveNext();
					}
					recordSet.Close();
				}
				if (recordSet != null)
				{
				}
				result = true;
				return result;
			}
			catch
			{
			}
			result = false;
			return result;
		}
		public static bool IndSwapFolderNumbers(string FolderName, int InFolderNo, int NewFolderNo)
		{
			bool result;
			try
			{
				string fullSearchString = "select * from SONG where FolderNo=" + InFolderNo.ToString();
				Database daoDb = gf.GetDaoDb(gf.ConnectStringMainDB);
				Recordset recordSet = gf.GetRecordSet(daoDb, fullSearchString);
				if (recordSet != null && !recordSet.EOF)
				{
					recordSet.MoveFirst();
					while (!recordSet.EOF)
					{
						recordSet.Edit();
						recordSet.Fields["FolderNo"].Value = NewFolderNo;
						recordSet.Update(1, false);
						recordSet.MoveNext();
					}
					recordSet.Close();
					fullSearchString = "select * from FOLDER  where FolderNo=" + InFolderNo.ToString();
					daoDb = gf.GetDaoDb(gf.ConnectStringMainDB);
					recordSet = gf.GetRecordSet(daoDb, fullSearchString);
					recordSet.MoveFirst();
					while (!recordSet.EOF)
					{
						recordSet.Edit();
						recordSet.Fields["FolderNo"].Value = NewFolderNo;
						recordSet.Update(1, false);
						recordSet.MoveNext();
					}
					recordSet.Close();
				}
				if (recordSet != null)
				{
				}
				result = true;
				return result;
			}
			catch
			{
			}
			result = false;
			return result;
		}
		public static bool ADOSwapFolderNumbers(string FolderName, int InFolderNo, int NewFolderNo)
		{
			bool result;
			try
			{
				OleDbConnection oleDbConnection = new OleDbConnection(gf.ConnectStringMainDB);
				oleDbConnection.Open();
				string text = "Update SONG SET FolderNo =@NewFolderNo where FolderNo=" + InFolderNo.ToString();
				OleDbCommand oleDbCommand = new OleDbCommand(text, oleDbConnection);
				oleDbCommand.CommandText = text;
				oleDbCommand.Parameters.AddWithValue("@NewFolderNo", NewFolderNo);
				oleDbCommand.ExecuteNonQuery();
				text = "Update FOLDER SET FolderNo =@NewFolderNo where FolderNo=" + InFolderNo.ToString();
				oleDbCommand.CommandText = text;
				oleDbCommand.Parameters.AddWithValue("@NewFolderNo", NewFolderNo);
				oleDbCommand.ExecuteNonQuery();
				oleDbCommand.Dispose();
				oleDbConnection.Close();
				oleDbConnection.Dispose();
				result = true;
				return result;
			}
			catch
			{
			}
			result = false;
			return result;
		}
		public static void SaveFormatStringToDatabase(string SongID, string FormatString)
		{
			try
			{
				Recordset tableRecordSet = gf.GetTableRecordSet(gf.ConnectStringMainDB, "SONG");
				tableRecordSet.Index = "PrimaryKey";
				tableRecordSet.Seek("=", SongID, gf.def, gf.def, gf.def, gf.def, gf.def, gf.def, gf.def, gf.def, gf.def, gf.def, gf.def, gf.def);
				if (!tableRecordSet.NoMatch)
				{
					tableRecordSet.Edit();
					tableRecordSet.Fields["FormatData"].Value = FormatString;
					tableRecordSet.Update(1, false);
				}
				if (tableRecordSet != null)
				{
					tableRecordSet.Close();
				}
			}
			catch
			{
			}
		}
		public static string BuildItemSearchString(string InString)
		{
			return gf.BuildItemSearchString(InString, true, true, true, true, true, true, true, true, false, "", "", false, DateTime.Now, DateTime.Now, null);
		}
		public static string BuildItemSearchString(string InString, bool SearchTitle, bool SearchContents, bool SearchSongNumber, bool SearchBookRef, bool SearchUserRef, bool SearchLicAdmin, bool SearchWriter, bool SearchCopyright, bool SearchNotationsOnly, string SearchSongKey, string SearchSongTiming, bool SearchDates, DateTime DateFrom, DateTime DateTo, CheckedListBox InFolderList)
		{
			string text = "";
			string text2 = "";
			string text3 = "";
			string text4 = "";
			string text5 = "";
			string text6 = "";
			string text7 = "";
			string text8 = "";
			string text9 = "";
			string text10 = "";
			string text11 = "";
			string text12 = "";
			string text13 = "";
			string text14 = "";
			string text15 = "*";
			bool flag = false;
			for (int i = 0; i <= InString.Length; i++)
			{
				if (gf.Mid(InString, i, 1) != "*")
				{
					text += gf.Mid(InString, i, 1);
				}
				else
				{
					text += text15;
				}
			}
			if (gf.Left(text, 1) != text15)
			{
				text = text15 + text;
			}
			if (gf.Right(text, 1) != text15)
			{
				text += text15;
			}
			for (int i = 1; i < 41; i++)
			{
				gf.FindSongsFolder[i] = false;
			}
			if (InFolderList != null)
			{
				for (int i = 0; i <= InFolderList.CheckedItems.Count - 1; i++)
				{
					gf.FindSongsFolder[gf.GetFolderNumber(InFolderList.CheckedItems[i].ToString())] = true;
					if (text2 == "")
					{
						text2 = " and (FolderNo=" + gf.GetFolderNumber(InFolderList.CheckedItems[i].ToString()).ToString();
					}
					else
					{
						text2 = text2 + " or FolderNo=" + gf.GetFolderNumber(InFolderList.CheckedItems[i].ToString()).ToString();
					}
				}
				if (text2 != "")
				{
					text2 += ")";
				}
			}
			else
			{
				for (int i = 1; i < 41; i++)
				{
					if (gf.FolderUse[i] > 0)
					{
						gf.FindSongsFolder[i] = true;
						if (text2 == "")
						{
							text2 = " and (FolderNo=" + i.ToString();
						}
						else
						{
							text2 = text2 + " or FolderNo=" + i.ToString();
						}
					}
				}
				if (text2 != "")
				{
					text2 += ")";
				}
			}
			if (SearchTitle)
			{
				text3 = string.Concat(new string[]
				{
					" (LCase(Title_1) like \"",
					text.ToLower(),
					"\" ",
					text2,
					") or (LCase(Title_2) like \"",
					text.ToLower(),
					"\" ",
					text2,
					")"
				});
				flag = true;
			}
			if (SearchContents)
			{
				text7 = string.Concat(new string[]
				{
					flag ? " OR " : "",
					" (LCase(lyrics) like \"",
					text.ToLower(),
					"\" ",
					text2,
					")"
				});
				flag = true;
			}
			int num = gf.StringToInt(text, true);
			if (SearchSongNumber)
			{
				if (num == 0)
				{
					text4 = (flag ? " OR " : "") + " ((song_number < 1 or song_number = NULL ) " + text2 + ")";
					flag = true;
				}
				else
				{
					if (num < 0)
					{
						text4 = string.Concat(new object[]
						{
							flag ? " OR " : "",
							" ((song_number >= ",
							num,
							"  and song_number <= ",
							num,
							") ",
							text2,
							")"
						});
						flag = true;
					}
				}
			}
			if (SearchBookRef)
			{
				text5 = string.Concat(new string[]
				{
					flag ? " OR " : "",
					" (LCase(BOOK_REFERENCE) like \"",
					text.ToLower(),
					"\" ",
					text2,
					")"
				});
				flag = true;
			}
			if (SearchUserRef)
			{
				text6 = string.Concat(new string[]
				{
					flag ? " OR " : "",
					" (LCase(USER_REFERENCE) like \"",
					text.ToLower(),
					"\" ",
					text2,
					")"
				});
				flag = true;
			}
			if (SearchLicAdmin)
			{
				text10 = string.Concat(new string[]
				{
					flag ? " OR " : "",
					" (LCase(licence_admin1) like \"",
					text.ToLower(),
					"\" ",
					text2,
					") or (LCase(licence_admin2) like \"",
					text.ToLower(),
					"\" ",
					text2,
					")"
				});
				flag = true;
			}
			if (SearchWriter)
			{
				text8 = string.Concat(new string[]
				{
					flag ? " OR " : "",
					" (LCase(writer) like \"",
					text.ToLower(),
					"\" ",
					text2,
					")"
				});
				flag = true;
			}
			if (SearchCopyright)
			{
				text9 = string.Concat(new string[]
				{
					flag ? " OR " : "",
					" (LCase(copyright) like \"",
					text.ToLower(),
					"\" ",
					text2,
					")"
				});
				flag = true;
			}
			if (SearchNotationsOnly)
			{
				text11 = (flag ? " AND " : "") + " (msc <> \"\")";
			}
			if (SearchSongKey != "")
			{
				text12 = (flag ? " AND " : "") + " (key = \"" + SearchSongKey + "\")";
			}
			if (SearchSongTiming != "")
			{
				text13 = (flag ? " AND " : "") + " (timing = \"" + SearchSongTiming + "\")";
			}
			if (SearchDates)
			{
				text14 = string.Concat(new string[]
				{
					flag ? " AND " : "",
					" LastModified >=#",
					DateFrom.ToString("MM-dd-yyyy"),
					"# and LastModified <=#",
					DateTo.ToString("MM-dd-yyyy"),
					"# "
				});
			}
			string text16 = string.Concat(new string[]
			{
				text3,
				text7,
				text4,
				text5,
				text6,
				text10,
				text8,
				text9
			});
			if (text16 != "")
			{
				text16 = "(" + text16 + ")";
			}
			if (text16 == "" & !gf.FindItemNotationsOnly)
			{
				text16 = " title_1 = \"@!@~!~\"";
			}
			return string.Concat(new string[]
			{
				"select * from SONG where ",
				text16,
				text12,
				text13,
				text11,
				text14
			});
		}
		public static string BuildBibleSearchString(string InSearchPassage, int VersionIndex)
		{
			return gf.BuildBibleSearchString(InSearchPassage, VersionIndex, 0, 2);
		}
		public static string BuildBibleSearchString(string InSearchPassage, int VersionIndex, int BookIndex, int MatchSelected)
		{
			string text = "\"*[ -/:-@]";
			string text2 = "[ -/:-@]*\"";
			if (gf.PartialWordSearch(VersionIndex))
			{
				text = "\"*";
				text2 = "*\"";
			}
			string result;
			if (gf.Trim(InSearchPassage).Length > 0)
			{
				InSearchPassage = gf.Trim(InSearchPassage.ToLower());
				gf.sArray = InSearchPassage.Split(new char[]
				{
					' '
				});
				string text3 = "";
				string text4 = "";
				string text5 = "";
				string text6 = "";
				string text7 = "select * from Bible where book";
				if (BookIndex < 1)
				{
					text7 += ">0 ";
				}
				else
				{
					text7 = text7 + "=" + BookIndex.ToString();
				}
				if (MatchSelected == 1)
				{
					for (int i = 0; i <= gf.sArray.GetUpperBound(0); i++)
					{
						if (i > 0)
						{
							text3 += " or ";
							text4 += " or ";
							text5 += " or ";
							text6 += " or ";
						}
						string text8 = text3;
						text3 = string.Concat(new string[]
						{
							text8,
							" LCase(bibletext) like ",
							text,
							gf.Trim(gf.sArray[i]),
							text2
						});
						text4 = text4 + " LCase(bibletext) like \"" + gf.Trim(gf.sArray[i]) + text2;
						text8 = text5;
						text5 = string.Concat(new string[]
						{
							text8,
							" LCase(bibletext) like ",
							text,
							gf.Trim(gf.sArray[i]),
							"\""
						});
						text6 = text6 + " LCase(bibletext) like \"" + gf.Trim(gf.sArray[i]) + "\"";
					}
				}
				else
				{
					if (MatchSelected == 0)
					{
						for (int i = 0; i <= gf.sArray.GetUpperBound(0); i++)
						{
							if (i > 0)
							{
								text3 += " and ";
								text4 += " and ";
								text5 += " and ";
								text6 += " and ";
							}
							string text8 = text3;
							text3 = string.Concat(new string[]
							{
								text8,
								" LCase(bibletext) like ",
								text,
								gf.sArray[i],
								text2
							});
							text4 = text4 + " LCase(bibletext) like \"" + gf.sArray[i] + text2;
							text8 = text5;
							text5 = string.Concat(new string[]
							{
								text8,
								" LCase(bibletext) like ",
								text,
								gf.sArray[i],
								"\""
							});
							text6 = text6 + " LCase(bibletext) like \"" + gf.sArray[i] + "\"";
						}
					}
					else
					{
						text3 = " LCase(bibletext) like " + text + gf.Trim(InSearchPassage).ToLower() + text2;
						text4 = " LCase(bibletext) like \"" + gf.Trim(InSearchPassage).ToLower() + text2;
						text5 = " LCase(bibletext) like " + text + gf.Trim(InSearchPassage).ToLower() + "\"";
						text6 = " LCase(bibletext) like \"" + gf.Trim(InSearchPassage).ToLower() + "\"";
					}
				}
				text3 = gf.Trim(text3);
				text4 = gf.Trim(text4);
				text5 = gf.Trim(text5);
				text6 = gf.Trim(text6);
				if (text3 != "")
				{
					text7 = text7 + " AND ( (" + text3 + ")";
					if (!gf.PartialWordSearch(VersionIndex))
					{
						string text8 = text7;
						text7 = string.Concat(new string[]
						{
							text8,
							" OR (",
							text4,
							") OR (",
							text5,
							") OR (",
							text6,
							")"
						});
					}
					text7 += " ) order by Book, chapter, verse ";
					result = text7;
					return result;
				}
			}
			result = "";
			return result;
		}
		public static bool PartialWordSearch(int VersionIndex)
		{
			bool result;
			try
			{
				string connectString = gf.ConnectStringDef + gf.HB_Versions[VersionIndex, 4];
				string fullSearchString = "select * from Bible where book=0 and chapter=0 and verse=20";
				Recordset recordSet = gf.GetRecordSet(connectString, fullSearchString);
				if (recordSet != null && !recordSet.EOF)
				{
					result = true;
					return result;
				}
			}
			catch
			{
			}
			result = false;
			return result;
		}
		public static bool SearchBiblePassages(int InBibleVersion, ref ComboBox InBookList, string InSelectString, ref RichTextBox InTextContainer, bool InShowVerses)
		{
			int num = 0;
			string connectString = gf.ConnectStringDef + gf.HB_Versions[InBibleVersion, 4];
			StringBuilder stringBuilder = new StringBuilder();
			Recordset recordSet = gf.GetRecordSet(connectString, InSelectString);
			bool result;
			if (recordSet != null && !recordSet.EOF)
			{
				recordSet.MoveFirst();
				while (!recordSet.EOF & num < 3000)
				{
					num++;
					int dataInt = gf.GetDataInt(recordSet, "book");
					int dataInt2 = gf.GetDataInt(recordSet, "chapter");
					int dataInt3 = gf.GetDataInt(recordSet, "verse");
					string str = string.Concat(new object[]
					{
						InBookList.Items[dataInt - 1],
						" ",
						dataInt2,
						":",
						dataInt3,
						" "
					});
					gf.HB_VersesLocation[num, 0] = InBibleVersion;
					gf.HB_VersesLocation[num, 1] = dataInt;
					gf.HB_VersesLocation[num, 2] = dataInt2;
					gf.HB_VersesLocation[num, 3] = dataInt3;
					gf.HB_VersesLocation[num, 4] = stringBuilder.Length;
					stringBuilder.Append(str + (InShowVerses ? gf.GetDataString(recordSet, "bibletext") : "") + "\n\n");
					gf.HB_VersesLocation[num, 5] = stringBuilder.Length + 1 - gf.HB_VersesLocation[num, 4];
					recordSet.MoveNext();
				}
				gf.HB_VersesLocation[0, 0] = num;
				InTextContainer.Text = gf.TrimEnd(stringBuilder.ToString());
				if (num >= 3000)
				{
					MessageBox.Show("The number of search results has been limited to " + Convert.ToString(3000) + ".");
				}
				result = true;
			}
			else
			{
				result = false;
			}
			return result;
		}
		public static bool FormInUse(string InFormName)
		{
			return gf.FindWindow(null, InFormName).ToInt32() > 0;
		}
		public static void SetMenuItem(ref ToolStripMenuItem InMenuItem, string ItemName, string DefaultText, string MergedText, bool DisableWhenBlank)
		{
			if (ItemName == "")
			{
				InMenuItem.Text = DefaultText;
				InMenuItem.Enabled = !DisableWhenBlank;
			}
			else
			{
				int num = 20;
				string str;
				if (ItemName.Length > num)
				{
					str = "...'";
				}
				else
				{
					str = "'";
				}
				InMenuItem.Text = MergedText + " '" + gf.Left(ItemName, num) + str;
				InMenuItem.Enabled = true;
			}
		}
		public static void Play_Media(string title1, string title2)
		{
			string mediaFileName = gf.GetMediaFileName(title1, title2);
			if (!gf.RunProcess(mediaFileName))
			{
				MessageBox.Show("Sorry, cannot find any media file for '" + title1 + "'" + ((title2 != "") ? (" or '" + title2 + "'") : ""));
			}
		}
		public static bool RunProcess(string InProcessString)
		{
			bool result;
			try
			{
				Process process = Process.Start(InProcessString);
			}
			catch
			{
				result = false;
				return result;
			}
			result = true;
			return result;
		}
		public static string LookupDBTitle2(int InKey)
		{
			string result;
			try
			{
				string fullSearchString = "select * from SONG where songid=" + Convert.ToString(InKey);
				Recordset recordSet = gf.GetRecordSet(gf.ConnectStringMainDB, fullSearchString);
				if (recordSet != null && !recordSet.EOF)
				{
					result = gf.ObjToString(recordSet.Fields["Title_2"].Value);
					return result;
				}
			}
			catch
			{
			}
			result = "";
			return result;
		}
		public static string UnicodeToAscii_RTF(string InString)
		{
			StringBuilder stringBuilder = new StringBuilder();
			for (int i = 0; i < InString.Length; i++)
			{
				string text = gf.Mid(InString, i, 1);
				if (text != "\r" & text != "\n" & text != "\t")
				{
					int num = (int)text[0];
					if (num < 0)
					{
						num += 65536;
					}
					if (num > 255)
					{
						stringBuilder.Append("\\u" + num.ToString("00000") + "?");
					}
					else
					{
						stringBuilder.Append(text);
					}
				}
				else
				{
					stringBuilder.Append(text);
				}
			}
			return stringBuilder.ToString();
		}
		public static string UnicodeToAscii_HTML(string InString)
		{
			StringBuilder stringBuilder = new StringBuilder();
			for (int i = 0; i < InString.Length; i++)
			{
				string text = gf.Mid(InString, i, 1);
				if (text != "\r" & text != "\n" & text != "\t")
				{
					int num = (int)text[0];
					if (num < 0)
					{
						num += 65536;
					}
					if (num > 255)
					{
						stringBuilder.Append("&#" + num.ToString("00000") + ";");
					}
					else
					{
						stringBuilder.Append(text);
					}
				}
				else
				{
					stringBuilder.Append(text);
				}
			}
			return stringBuilder.ToString();
		}
		public static string HexString(string InString)
		{
			StringBuilder stringBuilder = new StringBuilder();
			for (int i = 0; i < InString.Length; i++)
			{
				string text = gf.Mid(InString, i, 1);
				int num = (int)text[0];
				if (num < 0)
				{
					num += 65536;
				}
				if (num > 127)
				{
					stringBuilder.Append(num.ToString("x"));
				}
				else
				{
					stringBuilder.Append(text);
				}
			}
			return stringBuilder.ToString();
		}
		public static Font GetNewFont(string InFontName, int InFontSize, bool InBold, bool InItalic, bool InUnderline)
		{
			return gf.GetNewFont(InFontName, InFontSize, InBold, InItalic, InUnderline, true);
		}
		public static Font GetNewFont(string InFontName, int InFontSize, bool InBold, bool InItalic, bool InUnderline, bool ShowErrorMsg)
		{
			FontStyle fontStyle = FontStyle.Regular;
			if (InBold)
			{
				fontStyle |= FontStyle.Bold;
			}
			if (InItalic)
			{
				fontStyle |= FontStyle.Italic;
			}
			if (InUnderline)
			{
				fontStyle |= FontStyle.Underline;
			}
			Font result;
			try
			{
				result = new Font(InFontName, (float)InFontSize, fontStyle);
			}
			catch
			{
				if (ShowErrorMsg)
				{
				}
				result = new Font("Microsoft Sans Serif", (float)InFontSize, fontStyle);
			}
			return result;
		}
		public static string TransposeChord(string InNotation, int TransposeStep, int FlatSharpKey)
		{
			string result;
			if (InNotation == "")
			{
				result = "";
			}
			else
			{
				if (TransposeStep == 0)
				{
					result = InNotation;
				}
				else
				{
					string[] array = InNotation.Split(new char[]
					{
						'/'
					});
					string str = gf.TransposeOneChord(array[0], TransposeStep, false, FlatSharpKey);
					string str2 = "";
					if (array.GetUpperBound(0) > 0)
					{
						str2 = "/" + gf.TransposeOneChord(array[1], TransposeStep, true, FlatSharpKey);
					}
					result = str + str2;
				}
			}
			return result;
		}
		public static string TransposeOneChord(string InChord, int TransposeStep, bool accidentals, int FlatSharpKey)
		{
			int start = 0;
			bool flag = false;
			int num = -1;
			int num2 = 0;
			string text = gf.Left(InChord, 1);
			if (text == "[" || text == "{")
			{
				InChord = gf.Mid(InChord, 1);
			}
			else
			{
				text = "";
			}
			string text2 = gf.Left(InChord, 2);
			while (text2.Length > 0 & !flag)
			{
				start = text2.Length;
				for (int i = 0; i <= 11; i++)
				{
					if (gf.MusicMajorChords[i, 0] == text2 | gf.MusicMajorChords[i, 1] == text2)
					{
						flag = true;
						num = i;
						num2 = 0;
						i = 12;
					}
				}
				if (!flag)
				{
					for (int i = 0; i <= 11; i++)
					{
						if (gf.MusicMinorChords[i, 0] == text2 | gf.MusicMinorChords[i, 1] == text2)
						{
							flag = true;
							num = i;
							num2 = 1;
							i = 12;
						}
					}
				}
				if (!flag)
				{
					text2 = gf.Left(text2, text2.Length - 1);
				}
			}
			string result;
			if (flag)
			{
				if (FlatSharpKey < 0 || FlatSharpKey > 1)
				{
					FlatSharpKey = ((TransposeStep > 0) ? 1 : 0);
				}
				int num3 = num + TransposeStep;
				if (num3 < 0)
				{
					num3 = 11 + num3 + 1;
				}
				if (num3 > 11)
				{
					num3 = num3 - 11 - 1;
				}
				string str;
				if (num2 == 0)
				{
					str = gf.MusicMajorChords[num3, (FlatSharpKey > 0) ? 1 : 0];
				}
				else
				{
					str = gf.MusicMinorChords[num3, (FlatSharpKey > 0) ? 1 : 0];
				}
				result = text + str + gf.Mid(InChord, start);
			}
			else
			{
				result = text + InChord;
			}
			return result;
		}
		public static int TransposeKey(ref string InKey, int TransposeStep)
		{
			int result;
			if (InKey == "")
			{
				result = ((TransposeStep > 0) ? 1 : 0);
			}
			else
			{
				bool flag = false;
				int num = -1;
				int num2 = 0;
				for (int i = 0; i <= 11; i++)
				{
					if (gf.MusicMajorKeys[i] == InKey)
					{
						flag = true;
						num = i;
						num2 = 0;
						i = 12;
					}
				}
				if (!flag)
				{
					for (int i = 0; i <= 11; i++)
					{
						if (gf.MusicMinorKeys[i] == InKey)
						{
							flag = true;
							num = i;
							num2 = 1;
							i = 12;
						}
					}
				}
				if (flag)
				{
					int num3 = num + TransposeStep;
					if (num3 < 0)
					{
						num3 = 11 + num3 + 1;
					}
					if (num3 > 11)
					{
						num3 = num3 - 11 - 1;
					}
					string text;
					int num4;
					if (num2 == 0)
					{
						text = gf.MusicMajorKeys[num3];
						num4 = gf.MusicMajorKeysFlatSharp[num3];
					}
					else
					{
						text = gf.MusicMinorKeys[num3];
						num4 = gf.MusicMinorKeysFlatSharp[num3];
					}
					InKey = text;
					result = num4;
				}
				else
				{
					result = -1;
				}
			}
			return result;
		}
		public static bool ValidSongID(int InSongID)
		{
			bool result;
			try
			{
				string fullSearchString = "select * from SONG where songid=" + InSongID;
				Recordset recordSet = gf.GetRecordSet(gf.ConnectStringMainDB, fullSearchString);
				if (recordSet != null && !recordSet.EOF)
				{
					result = (gf.FolderUse[gf.ObjToInt(recordSet.Fields["FolderNo"].Value)] > 0);
					return result;
				}
			}
			catch
			{
			}
			result = false;
			return result;
		}
		public static void GetCurPosInLine(string instring, ref int CurPos)
		{
			gf.MoveToPosInLine(instring, ref CurPos, 0);
		}
		public static void MoveToPosInLine(string instring, ref int CurPos, int InMode)
		{
			if (instring.Length != 0)
			{
				bool flag = false;
				int num = CurPos + ((InMode == 0) ? -1 : 0);
				while (num >= 0 && num < instring.Length && !flag)
				{
					string a = gf.Mid(instring, num, 1);
					if (a == "\r" | a == "\n")
					{
						flag = true;
						CurPos = num + ((InMode == 0) ? 1 : 0);
						num = 0;
					}
					else
					{
						num += ((InMode == 0) ? -1 : 1);
					}
				}
				if (!flag)
				{
					CurPos = ((InMode == 0) ? 0 : instring.Length);
				}
			}
		}
		public static void InsertChordAboveCurrentLine(ref RichTextBox InTextBox, string InChordString)
		{
			int arg_21_0 = (InChordString[0].ToString() == "/") ? 1 : 0;
			int num = InTextBox.SelectionStart;
			int curPos = num;
			int num2 = num;
			int length = InTextBox.Text.Length;
			Point positionFromCharIndex = InTextBox.GetPositionFromCharIndex(num);
			int lineFromCharIndex = InTextBox.GetLineFromCharIndex(num);
			bool flag = false;
			int num3 = InTextBox.Text.IndexOf("»", num);
			if (InTextBox.GetLineFromCharIndex(num3) != lineFromCharIndex)
			{
				num3 = -1;
			}
			int num4 = -1;
			if (num3 >= 0)
			{
				num4 = num;
			}
			else
			{
				InChordString += " ";
				if (lineFromCharIndex < 1)
				{
					flag = true;
				}
				else
				{
					string textFromPreviousLine = gf.GetTextFromPreviousLine(InTextBox.Text, curPos);
					if (textFromPreviousLine.IndexOf("»") < 0)
					{
						flag = true;
					}
				}
				if (flag)
				{
					gf.InsertIndicator(ref InTextBox, 151);
					InTextBox.SelectionStart--;
					gf.InsertIndicator(ref InTextBox, 152);
					num = InTextBox.SelectionStart;
				}
				else
				{
					gf.GetCurPosInLine(InTextBox.Text, ref num);
					num--;
				}
			}
			int num5 = -1;
			gf.MoveToPosInLine(InTextBox.Text, ref num5, 1);
			gf.GetCurPosInLine(InTextBox.Text, ref num);
			int num6 = num;
			InTextBox.SelectionStart = num;
			num3 = InTextBox.Text.IndexOf("»", num);
			if (num3 >= 0)
			{
				if (num4 >= 0)
				{
					num = num4;
				}
				InTextBox.SelectionStart = num3;
				Point positionFromCharIndex2 = InTextBox.GetPositionFromCharIndex(InTextBox.SelectionStart);
				while (positionFromCharIndex2.X < positionFromCharIndex.X)
				{
					InTextBox.SelectedText = " ";
					positionFromCharIndex2 = InTextBox.GetPositionFromCharIndex(InTextBox.SelectionStart);
				}
				gf.GetCurPosInLine(InTextBox.Text, ref num);
				while (InTextBox.GetPositionFromCharIndex(num).X < positionFromCharIndex.X)
				{
					num++;
				}
				bool flag2 = false;
				while (num > num6 && num < num3 && !flag2)
				{
					if (InTextBox.Text[num - 1].ToString() == " ")
					{
						flag2 = true;
					}
					else
					{
						if (InTextBox.Text[num].ToString() == " ")
						{
							num++;
							flag2 = true;
						}
						else
						{
							num++;
						}
					}
				}
				Point positionFromCharIndex3 = new Point(-1, -1);
				int num7 = -1;
				for (int i = num; i <= num3; i++)
				{
					if (InTextBox.Text[i].ToString() != " ")
					{
						positionFromCharIndex3 = InTextBox.GetPositionFromCharIndex(i);
						num7 = i;
						i = num3 + 1;
					}
				}
				InTextBox.SelectionStart = num;
				InTextBox.SelectedText = InChordString;
				InTextBox.SelectedText = "";
				if (num7 >= 0)
				{
					num7 += InChordString.Length - 1;
					int x = InTextBox.GetPositionFromCharIndex(num7).X;
					while (x >= positionFromCharIndex3.X && InTextBox.Text[num7 - 1].ToString() == " " && InTextBox.Text[num7 - 2].ToString() == " ")
					{
						InTextBox.SelectionStart = num7;
						InTextBox.SelectionLength = 1;
						InTextBox.SelectedText = "";
						num7--;
						x = InTextBox.GetPositionFromCharIndex(num7).X;
					}
				}
				InTextBox.SelectionStart = ((num4 >= 0) ? (num4 + InChordString.Length) : (num2 + (InTextBox.Text.Length - length)));
				InTextBox.SelectedText = "";
			}
		}
		public static string GetTextFromPreviousLine(string InString, int CurPos)
		{
			gf.GetCurPosInLine(InString, ref CurPos);
			if (CurPos > 0)
			{
				CurPos--;
			}
			int num = CurPos;
			gf.GetCurPosInLine(InString, ref CurPos);
			int num2 = num - CurPos;
			string inString = "";
			if (num2 > 0)
			{
				inString = gf.Mid(InString, CurPos, num2);
			}
			return gf.Trim(inString);
		}
		public static void OldGetCurPosInLine(string instring, ref int CurPos, int InPos)
		{
			if (instring.Length != 0)
			{
				bool flag = false;
				int num = CurPos + 1 + ((InPos == 0) ? -1 : 0);
				while (num > 1 & num < instring.Length + 1)
				{
					if (gf.Mid(instring, num, 1) == "\r" | gf.Mid(instring, num, 1) == "\n")
					{
						flag = true;
						CurPos = num + ((InPos == 0) ? 0 : -1);
						num = 1;
					}
					else
					{
						num += ((InPos == 0) ? -1 : 1);
					}
				}
				if (!flag)
				{
					CurPos = ((InPos == 0) ? 0 : instring.Length);
				}
			}
		}
		public static string MakeTitleValidFileName(string InString)
		{
			char[] array = new char[]
			{
				'\\',
				'/',
				':',
				'*',
				'?',
				'"',
				'<',
				'>',
				'|'
			};
			for (int i = 0; i < array.Length; i++)
			{
				InString = InString.Replace(array[i], '_');
			}
			InString = gf.Left(InString, 255);
			return InString;
		}
		public static bool ValidateTitleDetails(string InString, string Heading)
		{
			char[] anyOf = new char[]
			{
				'[',
				']',
				'*',
				'"',
				'<',
				'>'
			};
			bool result;
			if (InString.IndexOfAny(anyOf) >= 0)
			{
				MessageBox.Show(Heading + " must not contain the characters: ] [ * \" < >");
				result = false;
			}
			else
			{
				if (InString.Length > 100)
				{
					MessageBox.Show(Heading + " is too long (" + Convert.ToString(InString.Length) + "), maximum length is 100 characters including spaces");
					result = false;
				}
				else
				{
					result = true;
				}
			}
			return result;
		}
		public static void FormatPlainLyrics(ref RichTextBox InTextBox)
		{
			string text = InTextBox.Text;
			string text2 = text.Replace("\r\n", "\n");
			text2 = text2.Replace("\r", "");
			for (int i = 99; i > 0; i--)
			{
				text2 = text2.Replace("Verse   " + i.ToString(), i.ToString());
				text2 = text2.Replace("verse   " + i.ToString(), i.ToString());
				text2 = text2.Replace("VERSE   " + i.ToString(), i.ToString());
				text2 = text2.Replace("Verse  " + i.ToString(), i.ToString());
				text2 = text2.Replace("verse  " + i.ToString(), i.ToString());
				text2 = text2.Replace("VERSE  " + i.ToString(), i.ToString());
				text2 = text2.Replace("Verse   " + i.ToString(), i.ToString());
				text2 = text2.Replace("verse   " + i.ToString(), i.ToString());
				text2 = text2.Replace("VERSE   " + i.ToString(), i.ToString());
				text2 = text2.Replace("Verse  " + i.ToString(), i.ToString());
				text2 = text2.Replace("verse  " + i.ToString(), i.ToString());
				text2 = text2.Replace("VERSE  " + i.ToString(), i.ToString());
				text2 = text2.Replace("Verse " + i.ToString(), i.ToString());
				text2 = text2.Replace("verse " + i.ToString(), i.ToString());
				text2 = text2.Replace("VERSE " + i.ToString(), i.ToString());
				text2 = text2.Replace("Verse" + i.ToString(), i.ToString());
				text2 = text2.Replace("verse" + i.ToString(), i.ToString());
				text2 = text2.Replace("VERSE" + i.ToString(), i.ToString());
				text2 = text2.Replace("Ver   " + i.ToString(), i.ToString());
				text2 = text2.Replace("ver   " + i.ToString(), i.ToString());
				text2 = text2.Replace("VER   " + i.ToString(), i.ToString());
				text2 = text2.Replace("Ver  " + i.ToString(), i.ToString());
				text2 = text2.Replace("ver  " + i.ToString(), i.ToString());
				text2 = text2.Replace("VER  " + i.ToString(), i.ToString());
				text2 = text2.Replace("Ver " + i.ToString(), i.ToString());
				text2 = text2.Replace("ver " + i.ToString(), i.ToString());
				text2 = text2.Replace("VER " + i.ToString(), i.ToString());
				text2 = text2.Replace("Ver" + i.ToString(), i.ToString());
				text2 = text2.Replace("ver" + i.ToString(), i.ToString());
				text2 = text2.Replace("VER" + i.ToString(), i.ToString());
				text2 = text2.Replace("V   " + i.ToString(), i.ToString());
				text2 = text2.Replace("v   " + i.ToString(), i.ToString());
				text2 = text2.Replace("V  " + i.ToString(), i.ToString());
				text2 = text2.Replace("v  " + i.ToString(), i.ToString());
				text2 = text2.Replace("V " + i.ToString(), i.ToString());
				text2 = text2.Replace("v " + i.ToString(), i.ToString());
				text2 = text2.Replace("V" + i.ToString(), i.ToString());
				text2 = text2.Replace("v" + i.ToString(), i.ToString());
			}
			if (text2.IndexOf("1") >= 0)
			{
				if (gf.Left(text2, 7) == "1.     ")
				{
					text2 = "[1]\n" + gf.Mid(text2, 8);
				}
				else
				{
					if (gf.Left(text2, 6) == "1.    ")
					{
						text2 = "[1]\n" + gf.Mid(text2, 7);
					}
					else
					{
						if (gf.Left(text2, 5) == "1.   ")
						{
							text2 = "[1]\n" + gf.Mid(text2, 6);
						}
						else
						{
							if (gf.Left(text2, 4) == "1.  ")
							{
								text2 = "[1]\n" + gf.Mid(text2, 5);
							}
							else
							{
								if (gf.Left(text2, 3) == "1. ")
								{
									text2 = "[1]\n" + gf.Mid(text2, 4);
								}
								else
								{
									if (gf.Left(text2, 2) == "1.")
									{
										text2 = "[1]\n" + gf.Mid(text2, 3);
									}
									else
									{
										if (gf.Left(text2, 7) == "1:     ")
										{
											text2 = "[1]\n" + gf.Mid(text2, 8);
										}
										else
										{
											if (gf.Left(text2, 6) == "1:    ")
											{
												text2 = "[1]\n" + gf.Mid(text2, 7);
											}
											else
											{
												if (gf.Left(text2, 5) == "1:   ")
												{
													text2 = "[1]\n" + gf.Mid(text2, 6);
												}
												else
												{
													if (gf.Left(text2, 4) == "1:  ")
													{
														text2 = "[1]\n" + gf.Mid(text2, 5);
													}
													else
													{
														if (gf.Left(text2, 3) == "1: ")
														{
															text2 = "[1]\n" + gf.Mid(text2, 4);
														}
														else
														{
															if (gf.Left(text2, 2) == "1:")
															{
																text2 = "[1]\n" + gf.Mid(text2, 3);
															}
															else
															{
																if (gf.Left(text2, 7) == "1      ")
																{
																	text2 = "[1]\n" + gf.Mid(text2, 8);
																}
																else
																{
																	if (gf.Left(text2, 6) == "1     ")
																	{
																		text2 = "[1]\n" + gf.Mid(text2, 7);
																	}
																	else
																	{
																		if (gf.Left(text2, 5) == "1    ")
																		{
																			text2 = "[1]\n" + gf.Mid(text2, 6);
																		}
																		else
																		{
																			if (gf.Left(text2, 4) == "1   ")
																			{
																				text2 = "[1]\n" + gf.Mid(text2, 5);
																			}
																			else
																			{
																				if (gf.Left(text2, 3) == "1  ")
																				{
																					text2 = "[1]\n" + gf.Mid(text2, 4);
																				}
																				else
																				{
																					if (gf.Left(text2, 2) == "1 ")
																					{
																						text2 = "[1]\n" + gf.Mid(text2, 3);
																					}
																					else
																					{
																						if (gf.Left(text2, 2) == "1\n")
																						{
																							text2 = "[1]\n" + gf.Mid(text2, 3);
																						}
																					}
																				}
																			}
																		}
																	}
																}
															}
														}
													}
												}
											}
										}
									}
								}
							}
						}
					}
				}
			}
			for (int i = 99; i > 0; i--)
			{
				if (text2.IndexOf(i.ToString()) >= 0)
				{
					text2 = text2.Replace("\n" + i.ToString() + ".     ", "\n[" + i.ToString() + "]\n");
					text2 = text2.Replace("\n" + i.ToString() + ".    ", "\n[" + i.ToString() + "]\n");
					text2 = text2.Replace("\n" + i.ToString() + ".   ", "\n[" + i.ToString() + "]\n");
					text2 = text2.Replace("\n" + i.ToString() + ".  ", "\n[" + i.ToString() + "]\n");
					text2 = text2.Replace("\n" + i.ToString() + ". ", "\n[" + i.ToString() + "]\n");
					text2 = text2.Replace("\n" + i.ToString() + ".", "\n[" + i.ToString() + "]\n");
					text2 = text2.Replace("\n" + i.ToString() + ":     ", "\n[" + i.ToString() + "]\n");
					text2 = text2.Replace("\n" + i.ToString() + ":    ", "\n[" + i.ToString() + "]\n");
					text2 = text2.Replace("\n" + i.ToString() + ":   ", "\n[" + i.ToString() + "]\n");
					text2 = text2.Replace("\n" + i.ToString() + ":  ", "\n[" + i.ToString() + "]\n");
					text2 = text2.Replace("\n" + i.ToString() + ": ", "\n[" + i.ToString() + "]\n");
					text2 = text2.Replace("\n" + i.ToString() + ":", "\n[" + i.ToString() + "]\n");
					text2 = text2.Replace("\n" + i.ToString() + "     ", "\n[" + i.ToString() + "]\n");
					text2 = text2.Replace("\n" + i.ToString() + "    ", "\n[" + i.ToString() + "]\n");
					text2 = text2.Replace("\n" + i.ToString() + "   ", "\n[" + i.ToString() + "]\n");
					text2 = text2.Replace("\n" + i.ToString() + "  ", "\n[" + i.ToString() + "]\n");
					text2 = text2.Replace("\n" + i.ToString() + " ", "\n[" + i.ToString() + "]\n");
					text2 = text2.Replace("\n" + i.ToString() + " ", "\n[" + i.ToString() + "]\n");
					text2 = text2.Replace("\n" + i.ToString() + "\n", "\n[" + i.ToString() + "]\n");
					text2 = text2.Replace("\n" + i.ToString() + "\t", "\n[" + i.ToString() + "]\n");
					text2 = text2.Replace("\n\n[" + i.ToString() + "]", "\n[" + i.ToString() + "]\n");
					text2 = text2.Replace("[" + i.ToString() + "]\n\n", "[" + i.ToString() + "]\n");
				}
			}
			string text3 = "ChoruS";
			string text4 = "[chorus]\n";
			text2 = text2.Replace("\nchorus", "\n" + text3);
			text2 = text2.Replace("\nChorus", "\n" + text3);
			text2 = text2.Replace("\nCHORUS", "\n" + text3);
			if (gf.Left(text2, 6) == "chorus")
			{
				text2 = text3 + gf.Mid(text2, 6);
			}
			if (gf.Left(text2, 6) == "Chorus")
			{
				text2 = text3 + gf.Mid(text2, 6);
			}
			if (gf.Left(text2, 6) == "CHORUS")
			{
				text2 = text3 + gf.Mid(text2, 6);
			}
			if (text2.IndexOf(text3) >= 0)
			{
				text2 = text2.Replace(text3 + ".     ", text4);
				text2 = text2.Replace(text3 + ".    ", text4);
				text2 = text2.Replace(text3 + ".   ", text4);
				text2 = text2.Replace(text3 + ".  ", text4);
				text2 = text2.Replace(text3 + ". ", text4);
				text2 = text2.Replace(text3 + ".", text4);
				text2 = text2.Replace(text3 + ":     ", text4);
				text2 = text2.Replace(text3 + ":    ", text4);
				text2 = text2.Replace(text3 + ":   ", text4);
				text2 = text2.Replace(text3 + ":  ", text4);
				text2 = text2.Replace(text3 + ": ", text4);
				text2 = text2.Replace(text3 + ":", text4);
				text2 = text2.Replace(text3 + "     ", text4);
				text2 = text2.Replace(text3 + "    ", text4);
				text2 = text2.Replace(text3 + "   ", text4);
				text2 = text2.Replace(text3 + "  ", text4);
				text2 = text2.Replace(text3 + " ", text4);
				text2 = text2.Replace(text3 + "\t", text4);
				text2 = text2.Replace(text3, text4);
				text2 = text2.Replace("\n\n" + text4, "\n" + text4);
				text2 = text2.Replace(text4 + "\n", text4);
			}
			if (text2.IndexOf("[2]") >= 0)
			{
				if (text2.IndexOf("[1]") < 0)
				{
					text2 = "[1]\n" + text2;
				}
			}
			text2 = text2.Replace("\t\n", "\n");
			text2 = text2.Replace("\t", "");
			text2 = text2.Replace("\n\n\n", "\n\n");
			text2 = text2.Replace("\n\n[", "\n[");
			text2 = gf.TrimEnd(text2);
			InTextBox.Text = text2;
		}
		public static void Merge_Songs(gf.SongSettings InItem1, gf.SongSettings InItem2, ref string CombinedLyrics, ref string CombinedNotations)
		{
			gf.FormatDisplayLyrics(ref InItem1, false, true);
			gf.FormatDisplayLyrics(ref InItem2, false, true);
			int[] array = new int[160];
			ListViewItem listViewItem = new ListViewItem();
			gf.TempItem1.LyricsAndNotationsList.Items.Clear();
			bool flag = false;
			for (int i = 0; i < InItem1.SongSequence.Length; i++)
			{
				int num = (int)InItem1.SongSequence[i];
				if (i == 0)
				{
					if (InItem1.CompleteLyrics.IndexOf(gf.VerseSymbol[num]) >= 0 || InItem2.CompleteLyrics.IndexOf(gf.VerseSymbol[num]) >= 0)
					{
						flag = true;
					}
				}
				listViewItem = gf.TempItem1.LyricsAndNotationsList.Items.Add(gf.VerseSymbol[num]);
				listViewItem.SubItems.Add("");
				int num2 = InItem1.VerseLineLoc[num, 1];
				while (num2 >= 0 & num2 <= InItem1.VerseLineLoc[num, 2])
				{
					listViewItem = gf.TempItem1.LyricsAndNotationsList.Items.Add(InItem1.LyricsAndNotationsList.Items[num2].SubItems[2].Text);
					listViewItem.SubItems.Add(InItem1.LyricsAndNotationsList.Items[num2].SubItems[3].Text);
					num2++;
				}
				if (InItem2.VersePresent[num] & InItem2.CompleteLyrics != "")
				{
					listViewItem = gf.TempItem1.LyricsAndNotationsList.Items.Add(gf.VerseSymbol[150]);
					listViewItem.SubItems.Add("");
					int num3 = InItem2.VerseLineLoc[num, 1];
					while (num3 >= 0 & num3 <= InItem2.VerseLineLoc[num, 2])
					{
						listViewItem = gf.TempItem1.LyricsAndNotationsList.Items.Add(InItem2.LyricsAndNotationsList.Items[num3].SubItems[2].Text);
						listViewItem.SubItems.Add(InItem2.LyricsAndNotationsList.Items[num3].SubItems[3].Text);
						num3++;
					}
					InItem2.VersePresent[num] = false;
				}
			}
			for (int i = 0; i <= 112; i++)
			{
				if (InItem2.VersePresent[i] & InItem2.CompleteLyrics != "")
				{
					int num = i;
					listViewItem = gf.TempItem1.LyricsAndNotationsList.Items.Add(gf.VerseSymbol[num]);
					listViewItem.SubItems.Add("");
					listViewItem = gf.TempItem1.LyricsAndNotationsList.Items.Add(gf.VerseSymbol[150]);
					listViewItem.SubItems.Add("");
					int num3 = InItem2.VerseLineLoc[num, 1];
					while (num3 >= 0 & num3 <= InItem2.VerseLineLoc[num, 2])
					{
						listViewItem = gf.TempItem1.LyricsAndNotationsList.Items.Add(InItem2.LyricsAndNotationsList.Items[num3].SubItems[2].Text);
						listViewItem.SubItems.Add(InItem2.LyricsAndNotationsList.Items[num3].SubItems[3].Text);
						num3++;
					}
				}
			}
			if (!flag)
			{
				if (gf.TempItem1.LyricsAndNotationsList.Items.Count > 0)
				{
					gf.TempItem1.LyricsAndNotationsList.Items[0].Remove();
				}
			}
			CombinedLyrics = "";
			for (int i = 0; i < gf.TempItem1.LyricsAndNotationsList.Items.Count; i++)
			{
				CombinedLyrics = CombinedLyrics + "\n" + gf.TempItem1.LyricsAndNotationsList.Items[i].SubItems[0].Text;
			}
			CombinedLyrics = gf.Mid(CombinedLyrics, 1);
			CombinedNotations = "";
			for (int i = 0; i < gf.TempItem1.LyricsAndNotationsList.Items.Count; i++)
			{
				if (gf.TempItem1.LyricsAndNotationsList.Items[i].SubItems[1].Text != "")
				{
					object obj = CombinedNotations;
					CombinedNotations = string.Concat(new object[]
					{
						obj,
						"(",
						Convert.ToString(i),
						';',
						gf.TempItem1.LyricsAndNotationsList.Items[i].SubItems[1].Text,
						")"
					});
				}
			}
			CombinedLyrics = gf.TrimEnd(CombinedLyrics);
		}
		public static bool UpdateRefString(string Instring, string InStringDelim, ref TextBox StoredTextBox, string StoredStringDelim)
		{
			string text = "";
			string[] array = Instring.Split(new char[]
			{
				InStringDelim[0]
			});
			string[] array2 = StoredTextBox.Text.Split(new char[]
			{
				StoredStringDelim[0]
			});
			for (int i = 0; i <= array.GetUpperBound(0); i++)
			{
				string a = gf.Trim(array[i]).ToLower();
				bool flag = false;
				if (a != "")
				{
					for (int j = 0; j <= array2.GetUpperBound(0); j++)
					{
						string b = gf.Trim(array2[j]).ToLower();
						if (a == b)
						{
							flag = true;
							j = array2.GetUpperBound(0) + 1;
						}
					}
					if (!flag)
					{
						text = text + ((text != "") ? (StoredStringDelim + " ") : "") + gf.Trim(array[i]);
					}
				}
			}
			bool result;
			if (text != "")
			{
				TextBox expr_14C = StoredTextBox;
				expr_14C.Text = expr_14C.Text + ((StoredTextBox.Text != "") ? (StoredStringDelim + " ") : "") + text;
				result = true;
			}
			else
			{
				result = false;
			}
			return result;
		}
		public static ListView ExtractLyrics(string InLyrics, string InNotations)
		{
			string text = "";
			string text2 = "";
			string text3 = "";
			string text4 = "";
			return gf.ExtractLyrics(InLyrics, InNotations, ref text, ref text2, ref text3, ref text4);
		}
		public static ListView ExtractLyrics(string InLyrics, string InNotations, ref string OutText1, ref string OutNotationString1, ref string OutText2, ref string OutNotationString2)
		{
			InLyrics = InLyrics.Replace("\r\n", "\n");
			ListView result;
			if (gf.IsNewR2Format(InLyrics))
			{
				result = gf.ExtractNewFormatLyrics(InLyrics, InNotations, ref OutText1, ref OutNotationString1, ref OutText2, ref OutNotationString2);
			}
			else
			{
				result = gf.ExtractDefaultFormatLyrics(InLyrics, InNotations, ref OutText1, ref OutNotationString1, ref OutText2, ref OutNotationString2);
			}
			return result;
		}
		public static ListView ExtractNewFormatLyrics(string InLyrics, string InNotations, ref string OutText1, ref string OutNotationString1, ref string OutText2, ref string OutNotationString2)
		{
			StringBuilder stringBuilder = new StringBuilder();
			StringBuilder stringBuilder2 = new StringBuilder();
			StringBuilder stringBuilder3 = new StringBuilder();
			StringBuilder stringBuilder4 = new StringBuilder();
			string text = "";
			string text2 = "";
			int num = -1;
			int num2 = -1;
			int num3 = -1;
			int num4 = -1;
			int num5 = 1;
			bool flag = false;
			string[] array = InLyrics.Split(new char[]
			{
				"\n"[0]
			});
			ListView listView = new ListView();
			gf.SetListViewColumns(listView, 4);
			listView.Items.Clear();
			ListViewItem listViewItem = new ListViewItem();
			for (int i = 0; i <= array.GetUpperBound(0); i++)
			{
				for (int j = 0; j <= gf.xArray.GetUpperBound(0); j++)
				{
					if (array[i] == gf.xArray[j])
					{
						if (array[i] != gf.VerseSymbol[150])
						{
							string curVerseSymbol = array[i];
							num4 = gf.GetVerseNumeric(curVerseSymbol);
							flag = true;
							j = gf.xArray.GetUpperBound(0) + 1;
						}
						else
						{
							num5 = 2;
						}
					}
				}
				if (num < i & InNotations.Length > 0)
				{
					num = gf.ExtractOneNotationsLine(ref InNotations, ref text);
				}
				if (num5 == 1)
				{
					num2++;
					stringBuilder.Append(array[i] + "\n");
					if (i == num)
					{
						text2 = gf.AddNotationLineNumber(text, num2);
						stringBuilder3.Append(text2);
						text2 = text;
					}
				}
				else
				{
					if (array[i] == gf.VerseSymbol[150])
					{
						flag = true;
					}
					else
					{
						num3++;
						stringBuilder2.Append(array[i] + "\n");
						if (i == num)
						{
							text2 = gf.AddNotationLineNumber(text, num3);
							stringBuilder4.Append(text2);
							text2 = text;
						}
					}
				}
				if (!flag)
				{
					if (num4 < 0)
					{
						num4 = 1;
					}
					listViewItem = listView.Items.Add(num4.ToString());
					listViewItem.SubItems.Add(num5.ToString());
					listViewItem.SubItems.Add(array[i]);
					listViewItem.SubItems.Add(text2);
				}
				flag = false;
				text2 = "";
			}
			OutText1 = gf.TrimEnd(stringBuilder.ToString());
			OutText2 = gf.TrimEnd(stringBuilder2.ToString());
			OutNotationString1 = stringBuilder3.ToString();
			OutNotationString2 = stringBuilder4.ToString();
			return listView;
		}
		public static ListView ExtractDefaultFormatLyrics(string InLyrics, string InNotations, ref string OutText1, ref string OutNotationString1, ref string OutText2, ref string OutNotationString2)
		{
			StringBuilder stringBuilder = new StringBuilder();
			StringBuilder stringBuilder2 = new StringBuilder();
			StringBuilder stringBuilder3 = new StringBuilder();
			StringBuilder stringBuilder4 = new StringBuilder();
			string text = "";
			string text2 = "";
			int num = -1;
			int num2 = -1;
			int num3 = -1;
			string text3 = "";
			int num4 = -1;
			int num5 = 1;
			bool flag = false;
			string[] array = InLyrics.Split(new char[]
			{
				"\n"[0]
			});
			ListView listView = new ListView();
			gf.SetListViewColumns(listView, 4);
			listView.Items.Clear();
			ListViewItem listViewItem = new ListViewItem();
			for (int i = 0; i <= array.GetUpperBound(0); i++)
			{
				for (int j = 0; j <= gf.xArray.GetUpperBound(0); j++)
				{
					if (array[i] == gf.xArray[j])
					{
						flag = true;
						if (array[i] != gf.VerseSymbol[150])
						{
							num5 = 1;
							text3 = array[i];
							num4 = gf.GetVerseNumeric(text3);
							j = gf.xArray.GetUpperBound(0) + 1;
						}
						else
						{
							num5 = 2;
						}
					}
				}
				if (num < i & InNotations.Length > 0)
				{
					num = gf.ExtractOneNotationsLine(ref InNotations, ref text);
				}
				if (num5 == 1)
				{
					num2++;
					stringBuilder.Append(array[i] + "\n");
					if (i == num)
					{
						text2 = gf.AddNotationLineNumber(text, num2);
						stringBuilder3.Append(text2);
						text2 = text;
					}
				}
				else
				{
					if (array[i] == gf.VerseSymbol[150])
					{
						if (text3 != "")
						{
							num3++;
							stringBuilder2.Append(text3 + "\n");
						}
					}
					else
					{
						num3++;
						stringBuilder2.Append(array[i] + "\n");
						if (i == num)
						{
							text2 = gf.AddNotationLineNumber(text, num3);
							stringBuilder4.Append(text2);
							text2 = text;
						}
					}
				}
				if (!flag)
				{
					if (num4 < 0)
					{
						num4 = 1;
					}
					listViewItem = listView.Items.Add(num4.ToString());
					listViewItem.SubItems.Add(num5.ToString());
					listViewItem.SubItems.Add(array[i]);
					listViewItem.SubItems.Add(text2);
				}
				flag = false;
				text2 = "";
			}
			OutText1 = gf.TrimEnd(stringBuilder.ToString());
			OutText2 = gf.TrimEnd(stringBuilder2.ToString());
			OutNotationString1 = stringBuilder3.ToString();
			OutNotationString2 = stringBuilder4.ToString();
			return listView;
		}
		private static int GetVerseNumeric(string CurVerseSymbol)
		{
			int result;
			for (int i = 0; i < 160; i++)
			{
				if (CurVerseSymbol == gf.VerseSymbol[i])
				{
					result = i;
					return result;
				}
			}
			result = -1;
			return result;
		}
		public static string AddNotationLineNumber(string InOneNotationLine, int InNewLineNumber)
		{
			string result;
			if (InOneNotationLine != "")
			{
				result = string.Concat(new object[]
				{
					"(",
					InNewLineNumber,
					';',
					InOneNotationLine,
					")"
				});
			}
			else
			{
				result = "";
			}
			return result;
		}
		public static void RemoveInvalidDirNameChars(ref string InString)
		{
			InString = InString.Replace("\\", "_");
			InString = InString.Replace("/", "_");
			InString = InString.Replace(":", "_");
			InString = InString.Replace("*", "_");
			InString = InString.Replace("?", "_");
			InString = InString.Replace("\"", "_");
			InString = InString.Replace("<", "_");
			InString = InString.Replace(">", "_");
			InString = InString.Replace("|", "_");
		}
		public static string RTFCheck(string InString)
		{
			InString = InString.Replace("{", "\\{");
			return InString.Replace("}", "\\}");
		}
		public static string Html_MusicDisplayName(string title1, string title2, string HTMLIndexDir)
		{
			string text = "";
			string text2 = "";
			string result;
			if (gf.GetMusicFileName(title1, title2, ref text, ref text2, true) == "")
			{
				result = "";
			}
			else
			{
				int num = 0;
				if (text == HTMLIndexDir)
				{
					result = text2;
				}
				else
				{
					for (int i = 0; i < HTMLIndexDir.Length; i++)
					{
						if (gf.Mid(HTMLIndexDir, i, 1) != gf.Mid(text, i, 1))
						{
							num = i - 1;
							i = HTMLIndexDir.Length;
						}
					}
					if (num < 1)
					{
						result = text + text2;
					}
					else
					{
						string str = "";
						for (int i = num + 1; i <= HTMLIndexDir.Length; i++)
						{
							if (gf.Mid(HTMLIndexDir, i, 1) == "\\")
							{
								str += "..\\";
							}
						}
						str += gf.Mid(text, num + 1);
						result = str + text2;
					}
				}
			}
			return result;
		}
		public static string GetMusicFileName(string MusicTitle1, string MusicTitle2)
		{
			string text = "";
			string text2 = "";
			return gf.GetMusicFileName(MusicTitle1, MusicTitle2, ref text, ref text2, false);
		}
		public static string GetMusicFileName(string MusicTitle1, string MusicTitle2, ref string DirPath)
		{
			string text = "";
			return gf.GetMusicFileName(MusicTitle1, MusicTitle2, ref DirPath, ref text, false);
		}
		public static string GetMusicFileName(string MusicTitle1, string MusicTitle2, ref string DirPath, ref string FileName)
		{
			return gf.GetMusicFileName(MusicTitle1, MusicTitle2, ref DirPath, ref FileName, false);
		}
		public static string GetMusicFileName(string MusicTitle1, string MusicTitle2, ref string DirPath, ref string FileName, bool StoreDirPath)
		{
			string result;
			if (StoreDirPath & gf.TotalMusicFiles < 1)
			{
				result = "";
			}
			else
			{
				for (int i = 0; i <= 1; i++)
				{
					string text = (i == 0) ? MusicTitle1 : MusicTitle2;
					for (int j = 0; j <= gf.TotalMediaFileExt - 1; j++)
					{
						if (StoreDirPath)
						{
							for (int k = 0; k <= gf.TotalMusicFiles - 1; k++)
							{
								if (gf.MediaFilesList[k, 0] == text)
								{
									if (gf.MediaFilesList[k, 1] == gf.MediaFileExtension[j, 0])
									{
										DirPath = gf.MediaFilesList[k, 2];
										FileName = gf.MediaFilesList[k, 0] + gf.MediaFilesList[k, 1];
										result = DirPath + FileName;
										return result;
									}
								}
							}
						}
						else
						{
							string musicFileNameFromDir = gf.GetMusicFileNameFromDir(gf.MediaDir, gf.MediaFileExtension[j, 0], text, ref DirPath, ref FileName);
							if (musicFileNameFromDir != "")
							{
								result = musicFileNameFromDir;
								return result;
							}
						}
					}
				}
				result = "";
			}
			return result;
		}
		public static string GetMusicFileNameFromDir(string FolderPath, string MusicExtension, string MusicTitle1)
		{
			string text = "";
			string text2 = "";
			return gf.GetMusicFileNameFromDir(FolderPath, MusicExtension, MusicTitle1, ref text, ref text2);
		}
		public static string GetMusicFileNameFromDir(string FolderPath, string MusicExtension, string MusicTitle1, ref string DirPath)
		{
			string text = "";
			return gf.GetMusicFileNameFromDir(FolderPath, MusicExtension, MusicTitle1, ref DirPath, ref text);
		}
		public static string GetMusicFileNameFromDir(string FolderPath, string MusicExtension, string MusicTitle1, ref string DirPath, ref string FileName)
		{
			string result;
			if (FolderPath == "" | !Directory.Exists(FolderPath) | gf.Mid(FolderPath, 2) == ":\\System Volume Information\\")
			{
				result = "";
			}
			else
			{
				if (File.Exists(FolderPath + MusicTitle1 + MusicExtension))
				{
					DirPath = FolderPath;
					FileName = MusicTitle1 + MusicExtension;
					result = DirPath + FileName;
				}
				else
				{
					string[] directories = Directory.GetDirectories(FolderPath);
					if (directories.Length > 0)
					{
						gf.SingleArraySort(directories, true);
					}
					string[] array = directories;
					for (int i = 0; i < array.Length; i++)
					{
						string str = array[i];
						string musicFileNameFromDir = gf.GetMusicFileNameFromDir(str + "\\", MusicExtension, MusicTitle1, ref DirPath, ref FileName);
						if (musicFileNameFromDir != "")
						{
							result = musicFileNameFromDir;
							return result;
						}
					}
					result = "";
				}
			}
			return result;
		}
		public static void AlertSettings(gf.AlertType InAlertType)
		{
			gf.ParentalAlertLive = false;
			gf.MessageAlertLive = false;
			gf.AlertTimeRemaining = 0;
			gf.Alert_FormattedMessage = "";
			gf.Alert_MessageHeight = 0;
			gf.Alert_MessageDisplayed = false;
			if (InAlertType == gf.AlertType.Parental)
			{
				gf.Alert_OriginalMessage = gf.Trim(gf.ParentalAlertHeading) + " " + gf.ParentalAlertDetails;
				gf.Alert_TextAlign = gf.ParentalAlertTextAlign;
				gf.Alert_VerticalAlign = gf.ParentalAlertVerticalAlign;
				gf.Alert_TextColour = gf.ParentalAlertTextColour;
				gf.Alert_BackColour = gf.ParentalAlertBackColour;
				gf.Alert_Flash = gf.ParentalAlertFlash;
				gf.Alert_Scroll = gf.ParentalAlertScroll;
				gf.Alert_Transparent = gf.ParentalAlertTransparent;
				gf.AlertTimeRemaining = gf.ParentalAlertDuration;
				gf.Alert_UserFont = gf.GetNewFont(gf.ParentalAlertFontName, gf.ParentalAlertFontSize, gf.ParentalAlertBold, gf.ParentalAlertItalic, gf.ParentalAlertUnderline, false);
				gf.Alert_UserFontShadow = gf.ParentalAlertShadow;
				gf.Alert_UserFontOutline = gf.ParentalAlertOutline;
				gf.BuildAlertSequence();
				gf.Alert_NewMessage = true;
				gf.ParentalAlertLive = true;
			}
			else
			{
				if (InAlertType == gf.AlertType.Message)
				{
					gf.Alert_OriginalMessage = gf.MessageAlertDetails;
					gf.Alert_TextAlign = gf.MessageAlertTextAlign;
					gf.Alert_VerticalAlign = gf.MessageAlertVerticalAlign;
					gf.Alert_TextColour = gf.MessageAlertTextColour;
					gf.Alert_BackColour = gf.MessageAlertBackColour;
					gf.Alert_Flash = gf.MessageAlertFlash;
					gf.Alert_Scroll = gf.MessageAlertScroll;
					gf.Alert_Transparent = gf.MessageAlertTransparent;
					gf.AlertTimeRemaining = gf.MessageAlertDuration;
					gf.Alert_UserFont = gf.GetNewFont(gf.MessageAlertFontName, gf.MessageAlertFontSize, gf.MessageAlertBold, gf.MessageAlertItalic, gf.MessageAlertUnderline, false);
					gf.Alert_UserFontShadow = gf.MessageAlertShadow;
					gf.Alert_UserFontOutline = gf.MessageAlertOutline;
					gf.BuildAlertSequence();
					gf.Alert_NewMessage = true;
					gf.MessageAlertLive = true;
				}
			}
		}
		public static void BuildAlertSequence()
		{
			string text = "";
			if (gf.Alert_Flash)
			{
				text = string.Concat(new object[]
				{
					"R",
					'>',
					"R",
					'>',
					"R",
					'>',
					"R",
					'>'
				});
			}
			gf.Alert_FormatSequence = text;
			bool flag = gf.Alert_Scroll;
			if ((gf.Alert_OriginalMessage.Length + 30) * gf.AlertGap > gf.AlertTimeRemaining)
			{
				flag = false;
			}
			if (flag)
			{
				for (int i = 0; i < gf.Alert_OriginalMessage.Length; i++)
				{
					gf.Alert_FormatSequence = gf.Alert_FormatSequence + "S" + '>';
				}
				gf.Alert_FormattedMessage = "";
				gf.Alert_MessageLength = 0;
			}
			else
			{
				if (!flag)
				{
					for (int i = 0; i < gf.Alert_OriginalMessage.Length; i++)
					{
						gf.Alert_FormatSequence = gf.Alert_FormatSequence + "A" + '>';
					}
					gf.Alert_FormattedMessage = "";
					gf.Alert_MessageLength = gf.Alert_OriginalMessage.Length;
				}
			}
			gf.Alert_FormatSequence += text;
			for (int i = 1; i <= 30; i++)
			{
				gf.Alert_FormatSequence = gf.Alert_FormatSequence + "A" + '>';
			}
			if (gf.Alert_Scroll)
			{
				gf.Alert_FormatSequence = gf.Alert_FormatSequence + "C" + '>';
			}
			gf.Alert_FormatOriginalSequence = gf.Alert_FormatSequence;
		}
		public static void OldBuildAlertSequence()
		{
			string text = "";
			if (gf.Alert_Flash)
			{
				text = string.Concat(new object[]
				{
					"R",
					'>',
					"R",
					'>',
					"R",
					'>',
					"R",
					'>'
				});
			}
			gf.Alert_FormatSequence = text;
			bool flag = gf.Alert_Scroll;
			if ((gf.Alert_OriginalMessage.Length + 30) * gf.AlertGap > gf.AlertTimeRemaining)
			{
				flag = false;
			}
			if (flag)
			{
				for (int i = 0; i < gf.Alert_OriginalMessage.Length; i++)
				{
					gf.Alert_FormatSequence = gf.Alert_FormatSequence + "S" + '>';
				}
				gf.Alert_FormattedMessage = "";
				gf.Alert_MessageLength = 0;
			}
			else
			{
				if (!flag)
				{
					for (int i = 0; i < gf.Alert_OriginalMessage.Length; i++)
					{
						gf.Alert_FormatSequence = gf.Alert_FormatSequence + "A" + '>';
					}
					gf.Alert_FormattedMessage = "";
					gf.Alert_MessageLength = gf.Alert_OriginalMessage.Length;
				}
			}
			gf.Alert_FormatSequence += text;
			for (int i = 1; i <= 30; i++)
			{
				gf.Alert_FormatSequence = gf.Alert_FormatSequence + "A" + '>';
			}
			if (gf.Alert_Scroll)
			{
				gf.Alert_FormatSequence = gf.Alert_FormatSequence + "C" + '>';
			}
			gf.Alert_FormatOriginalSequence = gf.Alert_FormatSequence;
		}
		public static void LoadComboBoxFromTextFile(ref ComboBox InComboBox, string InTextFile)
		{
			InComboBox.Items.Clear();
			string text = "";
			if (gf.LoadFileContents(InTextFile, ref text))
			{
				text = text.Replace("\r\n", "\n");
				try
				{
					string[] array = text.Split(new char[]
					{
						"\n"[0]
					});
					int num = 0;
					while (num <= array.GetUpperBound(0) & num < 20)
					{
						if (gf.Trim(array[num]) != "")
						{
							InComboBox.Items.Add(gf.Trim(array[num]));
						}
						num++;
					}
				}
				catch
				{
				}
			}
			InComboBox.Text = "";
		}
		public static void SaveComboBoxToTextFile(ref ComboBox InComboBox, string InTextFile)
		{
			string text = "";
			int num = 0;
			while (num < InComboBox.Items.Count & num < 20)
			{
				if (gf.Trim(InComboBox.Items[num].ToString()) != "")
				{
					text = text + gf.TrimEnd(gf.Trim(InComboBox.Items[num].ToString())) + "\r\n";
				}
				num++;
			}
			gf.CreateNewFile(InTextFile, gf.FileContentsType.DoubleByte, text);
		}
		public static void LoadListViewFromTextFile(ref ListView InListView, string InTextFile)
		{
			InListView.Items.Clear();
			string text = "";
			if (gf.LoadFileContents(InTextFile, ref text))
			{
				text = text.Replace("\r\n", "\n");
				try
				{
					string[] array = text.Split(new char[]
					{
						"\n"[0]
					});
					for (int i = 0; i <= array.GetUpperBound(0); i++)
					{
						if (gf.Trim(array[i]) != "")
						{
							InListView.Items.Add(gf.Trim(array[i]));
						}
					}
				}
				catch
				{
				}
			}
			InListView.Text = "";
		}
		public static void SaveListViewToTextFile(ref ListView InListView, string InTextFile)
		{
			string text = "";
			for (int i = 0; i < InListView.Items.Count; i++)
			{
				if (gf.Trim(InListView.Items[i].Text) != "")
				{
					text = text + gf.TrimEnd(gf.Trim(InListView.Items[i].Text)) + "\r\n";
				}
			}
			gf.CreateNewFile(InTextFile, gf.FileContentsType.DoubleByte, text);
		}
		public static void MapLyricsBreak(ref ListView InScreenBreak, ref RichTextBox InLyrics, ref bool ScreenBreakListDone)
		{
			int i = 0;
			int num = 0;
			string text = "";
			bool flag = false;
			InLyrics.Text.Replace("\r\n", "\n");
			InLyrics.Text = gf.TrimStart(InLyrics.Text);
			InScreenBreak.Items.Clear();
			InLyrics.Focus();
			while (i >= 0)
			{
				int num2 = InLyrics.Text.IndexOf("[", (i < InLyrics.Text.Length) ? i : InLyrics.Text.Length);
				int num3 = InLyrics.Text.IndexOf("\n\n", (i < InLyrics.Text.Length) ? i : InLyrics.Text.Length);
				if (!flag)
				{
					if (num2 != 0 && num3 != 0)
					{
						num2 = -1;
						num3 = 0;
					}
				}
				if (num2 >= 0 & num3 >= 0)
				{
					if (num2 < num3)
					{
						string text2 = gf.ValidateVerseIndicator(InLyrics.Text, num2);
						if (text2 != "")
						{
							if (text != text2)
							{
								num = 0;
							}
							text = text2;
							gf.AddItemToScreenBreak(ref InScreenBreak, num2, text, num);
							num++;
							i = text.Length + num2;
						}
					}
					else
					{
						gf.AddItemToScreenBreak(ref InScreenBreak, num3 + (flag ? 2 : 0), text, num);
						num++;
						i = 2 + num3;
					}
				}
				else
				{
					if (num2 >= 0)
					{
						string text2 = gf.ValidateVerseIndicator(InLyrics.Text, num2);
						if (text2 != "")
						{
							if (text != text2)
							{
								num = 0;
							}
							text = text2;
							gf.AddItemToScreenBreak(ref InScreenBreak, num2, text, num);
							num++;
							i = text.Length + num2;
						}
					}
					else
					{
						if (num3 >= 0)
						{
							gf.AddItemToScreenBreak(ref InScreenBreak, num3 + (flag ? 2 : 0), text, num);
							num++;
							i = 2 + num3;
						}
						else
						{
							i = -1;
						}
					}
				}
				flag = true;
			}
			ScreenBreakListDone = true;
		}
		public static string ValidateVerseIndicator(string InText, int StartPosition)
		{
			string result;
			for (int i = 0; i <= 99; i++)
			{
				if (gf.Mid(InText, StartPosition, gf.VerseSymbol[i].Length) == gf.VerseSymbol[i])
				{
					result = gf.VerseSymbol[i];
					return result;
				}
			}
			for (int i = 100; i <= 112; i++)
			{
				if (gf.Mid(InText, StartPosition, gf.VerseSymbol[i].Length) == gf.VerseSymbol[i])
				{
					result = gf.VerseSymbol[i];
					return result;
				}
			}
			result = "";
			return result;
		}
		public static void AddItemToScreenBreak(ref ListView InListView, int NewPosition, string VerseSym, int ScreenBreakCount)
		{
			ListViewItem listViewItem = new ListViewItem();
			listViewItem = InListView.Items.Add(NewPosition.ToString());
			listViewItem.SubItems.Add(VerseSym);
			listViewItem.SubItems.Add(ScreenBreakCount.ToString());
		}
		public static void GetBreakPosition(ListView InListView, int CurPosition, int Direction, ref int NewPosition, ref int NewPositionLength, ref string LookupVerseSym, ref int LookupScreenCount)
		{
			if (InListView.Items.Count == 0)
			{
				LookupVerseSym = "";
				NewPosition = 0;
				NewPositionLength = -1;
				LookupScreenCount = 0;
			}
			else
			{
				int num;
				if (Direction == 0)
				{
					for (int i = InListView.Items.Count - 1; i >= 0; i--)
					{
						if (gf.StringToInt(InListView.Items[i].SubItems[0].Text) < CurPosition)
						{
							num = i;
							goto IL_110;
						}
					}
					num = 0;
				}
				else
				{
					for (int i = 0; i < InListView.Items.Count; i++)
					{
						if (gf.StringToInt(InListView.Items[i].SubItems[0].Text) > CurPosition)
						{
							if (NewPositionLength == 0)
							{
								if (i > 0)
								{
									i--;
								}
							}
							num = i;
							goto IL_110;
						}
					}
					num = InListView.Items.Count - 1;
				}
				IL_110:
				NewPosition = gf.StringToInt(InListView.Items[num].SubItems[0].Text);
				LookupVerseSym = InListView.Items[num].SubItems[1].Text;
				LookupScreenCount = gf.StringToInt(InListView.Items[num].SubItems[2].Text);
				if (num < InListView.Items.Count - 1)
				{
					int num2 = gf.StringToInt(InListView.Items[num + 1].SubItems[0].Text);
					NewPositionLength = num2 - NewPosition;
				}
				else
				{
					NewPositionLength = -1;
				}
			}
		}
		public static void GetBreakPosition(ListView InListView, ref int NewPosition, ref int NewPositionLength, string LookupVerseSym, int LookupScreenCount)
		{
			if (InListView.Items.Count == 0)
			{
				LookupVerseSym = "";
				NewPosition = 0;
				NewPositionLength = 0;
				LookupScreenCount = 0;
			}
			else
			{
				int num = -1;
				for (int i = 0; i < InListView.Items.Count; i++)
				{
					if (InListView.Items[i].SubItems[1].Text == LookupVerseSym && gf.StringToInt(InListView.Items[i].SubItems[2].Text) == LookupScreenCount)
					{
						num = i;
						IL_C0:
						NewPosition = gf.StringToInt(InListView.Items[num].SubItems[0].Text);
						if (num < InListView.Items.Count - 1)
						{
							int num2 = gf.StringToInt(InListView.Items[num + 1].SubItems[0].Text);
							NewPositionLength = num2 - NewPosition;
						}
						else
						{
							NewPositionLength = -1;
						}
						return;
					}
				}
				if (num >= 0)
				{
					//goto 1;
				}
				LookupVerseSym = "";
				NewPosition = 0;
				NewPositionLength = 0;
				LookupScreenCount = 0;
			}
		}
		public static bool RecycleBin(string FullFileName)
		{
			bool result;
			try
			{
				gf.SHFILEOPSTRUCT sHFILEOPSTRUCT = default(gf.SHFILEOPSTRUCT);
				sHFILEOPSTRUCT.hwnd = IntPtr.Zero;
				sHFILEOPSTRUCT.wFunc = 3u;
				sHFILEOPSTRUCT.fFlags = 80;
				sHFILEOPSTRUCT.pFrom = FullFileName + '\0' + '\0';
				sHFILEOPSTRUCT.fAnyOperationsAborted = 0;
				sHFILEOPSTRUCT.hNameMappings = IntPtr.Zero;
				gf.SHFileOperation(ref sHFILEOPSTRUCT);
				result = !File.Exists(FullFileName);
			}
			catch
			{
				result = false;
			}
			return result;
		}
		public static string CopyExternalFile(string SourceFileName, string CopyToFolder)
		{
			string result;
			if (File.Exists(SourceFileName))
			{
				int num = 0;
				string extension = Path.GetExtension(SourceFileName);
				string displayNameOnly = gf.GetDisplayNameOnly(ref SourceFileName, false);
				string text = Path.GetDirectoryName(SourceFileName) + "\\";
				if (!Directory.Exists(CopyToFolder))
				{
					if (!gf.MakeDir(CopyToFolder))
					{
						result = "";
						return result;
					}
				}
				string text2 = CopyToFolder + displayNameOnly + extension;
				while (File.Exists(text2))
				{
					num++;
					text2 = string.Concat(new string[]
					{
						CopyToFolder,
						displayNameOnly,
						" - Copy (",
						num.ToString(),
						")",
						extension
					});
				}
				try
				{
					File.Copy(SourceFileName, text2);
					result = text2;
					return result;
				}
				catch
				{
				}
			}
			result = "";
			return result;
		}
		public static string MoveExternalFile(string SourceFileName, string MoveToFolder)
		{
			string result;
			if (File.Exists(SourceFileName))
			{
				int num = 0;
				string extension = Path.GetExtension(SourceFileName);
				string displayNameOnly = gf.GetDisplayNameOnly(ref SourceFileName, false);
				string text = Path.GetDirectoryName(SourceFileName) + "\\";
				if (!Directory.Exists(MoveToFolder))
				{
					if (!gf.MakeDir(MoveToFolder))
					{
						result = "";
						return result;
					}
				}
				string text2 = MoveToFolder + displayNameOnly + extension;
				while (File.Exists(text2))
				{
					num++;
					text2 = string.Concat(new string[]
					{
						MoveToFolder,
						displayNameOnly,
						" - Copy (",
						num.ToString(),
						")",
						extension
					});
				}
				try
				{
					File.Move(SourceFileName, text2);
					result = text2;
					return result;
				}
				catch
				{
				}
			}
			result = "";
			return result;
		}
		public static void ScanSelectedRTB(ref RichTextBox InTextBox, bool[] VersePresent, bool DoAll, int StartPos, int EndPos, string[] InsArray, Font MainFont, Font NotationFont, bool DoNotations)
		{
			if (!(InTextBox.Text == ""))
			{
				int selectionStart = EndPos;
				if (DoAll)
				{
					StartPos = 0;
					EndPos = InTextBox.Text.Length - 1;
				}
				else
				{
					if (StartPos > EndPos)
					{
						StartPos = EndPos;
						EndPos = StartPos;
					}
					gf.MoveToPosInLine(InTextBox.Text, ref StartPos, 0);
					gf.MoveToPosInLine(InTextBox.Text, ref EndPos, 1);
				}
				int i = 0;
				gf.MarkSelectedRTB(ref InTextBox, StartPos, EndPos - StartPos + 1, 0, MainFont, NotationFont);
				for (i = 0; i <= InsArray.GetUpperBound(0); i++)
				{
					if (StartPos < 0)
					{
						StartPos = 0;
					}
					if (InsArray[i] == gf.VerseSymbol[150])
					{
						int j;
						try
						{
							j = InTextBox.Text.IndexOf(InsArray[i], StartPos);
						}
						catch
						{
							j = -1;
						}
						while (j >= 0)
						{
							gf.MarkSelectedRTB(ref InTextBox, j, InsArray[i].Length, 1, MainFont, NotationFont);
							j = InTextBox.Text.IndexOf(InsArray[i], j + 1);
						}
					}
					else
					{
						int j;
						try
						{
							j = InTextBox.Text.IndexOf(InsArray[i], StartPos);
						}
						catch
						{
							j = -1;
						}
						if (j >= 0 & j <= EndPos)
						{
							gf.MarkSelectedRTB(ref InTextBox, j, InsArray[i].Length, 1, MainFont, NotationFont);
						}
					}
				}
				if (DoNotations)
				{
					int j;
					try
					{
						j = InTextBox.Text.IndexOf("»", StartPos);
					}
					catch
					{
						j = -1;
					}
					while (j >= 0 & j <= EndPos)
					{
						int num = j;
						int num2 = j;
						gf.MoveToPosInLine(InTextBox.Text, ref num, 0);
						gf.MoveToPosInLine(InTextBox.Text, ref num2, 1);
						gf.MarkSelectedRTB(ref InTextBox, num, num2 - num + 1, 2, MainFont, NotationFont);
						j = InTextBox.Text.IndexOf("»", j + 1);
					}
				}
				InTextBox.SelectionStart = selectionStart;
			}
		}
		public static void MarkSelectedRTB(ref RichTextBox InTextBox, int SelStartPos, int SelLen, int InMode, Font MainFont, Font NotationFont)
		{
			gf.SendMessage(InTextBox.Handle, 11u, 0u, 0u);
			InTextBox.SelectionStart = SelStartPos;
			InTextBox.SelectionLength = SelLen;
			if (InMode == 0)
			{
				InTextBox.SelectionCharOffset = 0;
				InTextBox.SelectionFont = MainFont;
				InTextBox.SelectionColor = gf.NormalTextColour;
			}
			else
			{
				if (InMode == 1)
				{
					InTextBox.SelectionCharOffset = 0;
					InTextBox.SelectionFont = MainFont;
					InTextBox.SelectionColor = gf.SelectedTextColour;
				}
				else
				{
					if (InMode == 2)
					{
						InTextBox.SelectionCharOffset = 0;
						InTextBox.SelectionFont = NotationFont;
						InTextBox.SelectionColor = gf.NotationColour;
					}
				}
			}
			InTextBox.SelectionStart = SelStartPos + SelLen;
			InTextBox.SelectionLength = 0;
			InTextBox.SelectionColor = gf.NormalTextColour;
			gf.SendMessage(InTextBox.Handle, 11u, 1u, 0u);
			InTextBox.Refresh();
		}
		public static bool SaveXMLInfoScreen(gf.SongSettings InItem, string InFileName, string[] InHeaderData, bool ReloadImageData, bool UseOriginalNotations)
		{
			bool result;
			try
			{
				XmlTextWriter xmlTextWriter = new XmlTextWriter(InFileName, Encoding.UTF8);
				xmlTextWriter.Formatting = Formatting.Indented;
				xmlTextWriter.WriteStartDocument();
				xmlTextWriter.WriteStartElement("EasiSlides");
				gf.WriteXMLOneItem(ref xmlTextWriter, InItem, InHeaderData, ReloadImageData, UseOriginalNotations);
				xmlTextWriter.WriteEndDocument();
				xmlTextWriter.Flush();
				xmlTextWriter.Close();
				result = true;
			}
			catch
			{
				result = false;
			}
			return result;
		}
		public static void WriteXMLOneItem(ref XmlTextWriter xtw, gf.SongSettings InItem, string[] InHeaderData, bool ReloadImageData)
		{
			gf.WriteXMLOneItem(ref xtw, InItem, InHeaderData, ReloadImageData, true);
		}
		public static void WriteXMLOneItem(ref XmlTextWriter xtw, gf.SongSettings InItem, string[] InHeaderData, bool ReloadImageData, bool UseOriginalNotations)
		{
			string text = InItem.Format.FormatString;
			if (InHeaderData != null)
			{
				for (int i = 2; i <= 254; i++)
				{
					if (InHeaderData[i] != "" && InHeaderData[i] != null)
					{
						object obj = text;
						text = string.Concat(new object[]
						{
							obj,
							(char)i,
							"=",
							InHeaderData[i],
							'>'.ToString()
						});
					}
				}
			}
			try
			{
				xtw.WriteStartElement("Item");
				xtw.WriteElementString("Title1", InItem.Title);
				xtw.WriteElementString("Title2", InItem.Title2);
				xtw.WriteElementString("Folder", gf.FolderName[InItem.FolderNo]);
				xtw.WriteElementString("SongNumber", InItem.SongNumber.ToString());
				InItem.CompleteLyrics = InItem.CompleteLyrics.Replace("\r\n", "\n");
				InItem.CompleteLyrics = InItem.CompleteLyrics.Replace("\n", "\r\n");
				xtw.WriteElementString("Contents", InItem.CompleteLyrics);
				xtw.WriteElementString("Notations", UseOriginalNotations ? InItem.OriginalNotations : InItem.Notations);
				xtw.WriteElementString("Sequence", gf.ConvertSequenceToTextString(InItem.SongSequence));
				xtw.WriteElementString("Writer", InItem.Writer);
				xtw.WriteElementString("Copyright", InItem.Copyright);
				xtw.WriteElementString("Category", InItem.Category);
				xtw.WriteElementString("Timing", InItem.Timing);
				xtw.WriteElementString("MusicKey", InItem.MusicKey);
				xtw.WriteElementString("Capo", InItem.Capo.ToString());
				xtw.WriteElementString("LicenceAdmin1", InItem.Show_LicAdminInfo1);
				xtw.WriteElementString("LicenceAdmin2", InItem.Show_LicAdminInfo2);
				xtw.WriteElementString("BookReference", InItem.Book_Reference);
				xtw.WriteElementString("UserReference", InItem.User_Reference);
				xtw.WriteElementString("FormatData", text);
				xtw.WriteElementString("Settings", InItem.Settings);
				if (ReloadImageData && InItem.Format.BackgroundPicture != null && InItem.Format.BackgroundPicture != "")
				{
					gf.Base64EncodeImageFile(ref xtw, "Image", InItem.Format.BackgroundPicture);
				}
				else
				{
					if (InItem.Format.ImageString != "")
					{
						xtw.WriteElementString("Image", InItem.Format.ImageString);
					}
				}
				xtw.WriteEndElement();
			}
			catch
			{
			}
		}
		public static void Base64EncodeImageFile(ref XmlTextWriter xtw, string InElementString, string InFileName)
		{
			FileInfo fileInfo = new FileInfo(InFileName);
			FileStream fileStream = fileInfo.OpenRead();
			byte[] array = new byte[fileInfo.Length];
			fileStream.Read(array, 0, array.Length);
			fileStream.Close();
			xtw.WriteStartElement(InElementString);
			xtw.WriteBase64(array, 0, array.Length);
		}
		public static string ConvertSequenceToTextString(string InSequence)
		{
			string result;
			if (InSequence.Length > 0)
			{
				string text = "";
				for (int i = 0; i < InSequence.Length; i++)
				{
					int num = (int)InSequence[i];
					if (num > 0 & num < 13)
					{
						text += num.ToString();
					}
					else
					{
						text += gf.SequenceSymbol[num];
					}
					if (i < InSequence.Length - 1)
					{
						text += ",";
					}
				}
				result = text;
			}
			else
			{
				result = "";
			}
			return result;
		}
		public static string ConvertTextStringToSequence(string InSequence)
		{
			string result;
			if (InSequence.Length > 0)
			{
				InSequence = InSequence.ToLower();
				string text = "";
				while (InSequence != "")
				{
					string text2 = gf.ExtractOneInfo(ref InSequence, ',');
					int num = -1;
					if (text2 != "")
					{
						string text3 = text2;
						if (text3 == null)
						{
							goto IL_124;
						}
                        //if (<PrivateImplementationDetails>{36B6D676-97AF-4003-A45B-DE52C4771E33}.$$method0x60003b1-1 == null)
                        //{
                        //    <PrivateImplementationDetails>{36B6D676-97AF-4003-A45B-DE52C4771E33}.$$method0x60003b1-1 = new Dictionary<string, int>(7)
                        //    {

                        //        {
                        //            "c",
                        //            0
                        //        },

                        //        {
                        //            "b",
                        //            1
                        //        },

                        //        {
                        //            "w",
                        //            2
                        //        },

                        //        {
                        //            "e",
                        //            3
                        //        },

                        //        {
                        //            "t",
                        //            4
                        //        },

                        //        {
                        //            "p",
                        //            5
                        //        },

                        //        {
                        //            "q",
                        //            6
                        //        }
                        //    };
                        //}
						int num2=0;
                        //if (!<PrivateImplementationDetails>{36B6D676-97AF-4003-A45B-DE52C4771E33}.$$method0x60003b1-1.TryGetValue(text3, out num2))
                        //{
                        //    goto IL_124;
                        //}
						switch (num2)
						{
						case 0:
							num = 0;
							break;
						case 1:
							num = 100;
							break;
						case 2:
							num = 103;
							break;
						case 3:
							num = 101;
							break;
						case 4:
							num = 102;
							break;
						case 5:
							num = 111;
							break;
						case 6:
							num = 112;
							break;
						default:
							goto IL_124;
						}
						goto IL_148;
						IL_124:
						num = gf.StringToInt(text2, true);
						if (num > 9 || num < 0)
						{
							num = -1;
						}
					}
					IL_148:
					if (num >= 0)
					{
						text += (char)num;
					}
				}
				result = text;
			}
			else
			{
				result = "";
			}
			return result;
		}
		public static string FormatMode(int InPart)
		{
			int num = gf.PB_WordsBold[InPart];
			int num2 = gf.PB_WordsItalic[InPart];
			int num3 = gf.PB_WordsUnderline[InPart];
			string str = "\\cf" + Convert.ToString(InPart + 1);
			string str2;
			if (num > 0)
			{
				if (num2 > 0)
				{
					if (num3 > 0)
					{
						str2 = "\\b\\i\\ul ";
					}
					else
					{
						str2 = "\\b\\i\\ulnone ";
					}
				}
				else
				{
					if (num3 > 0)
					{
						str2 = "\\b\\i0\\ul ";
					}
					else
					{
						str2 = "\\b\\i0\\ulnone ";
					}
				}
			}
			else
			{
				if (num2 > 0)
				{
					if (num3 > 0)
					{
						str2 = "\\b0\\i\\ul ";
					}
					else
					{
						str2 = "\\b0\\i\\ulnone ";
					}
				}
				else
				{
					if (num3 > 0)
					{
						str2 = "\\b0\\i0\\ul ";
					}
					else
					{
						str2 = "\\b0\\i0\\ulnone ";
					}
				}
			}
			return "\\fs" + Convert.ToString(gf.PB_WordsSize[InPart] * 2) + str + str2;
		}
		public static bool LoadDataIntoItem(ref gf.SongSettings InItem, Recordset rs, string InID)
		{
			bool result;
			try
			{
				rs.Seek("=", InID, gf.def, gf.def, gf.def, gf.def, gf.def, gf.def, gf.def, gf.def, gf.def, gf.def, gf.def, gf.def);
				if (!rs.NoMatch)
				{
					result = gf.LoadDataIntoItem(ref InItem, rs);
					return result;
				}
				gf.InitialiseIndividualData(ref InItem);
			}
			catch
			{
			}
			result = false;
			return result;
		}
		public static bool LoadDataIntoItem(ref gf.SongSettings InItem, Recordset rs)
		{
			gf.InitialiseIndividualData(ref InItem);
			bool result;
			try
			{
				InItem.Title = gf.GetDataString(rs, "Title_1");
				InItem.Title2 = gf.GetDataString(rs, "Title_2");
				InItem.SongNumber = gf.GetDataInt(rs, "song_number");
				InItem.CompleteLyrics = gf.GetDataString(rs, "Lyrics");
				InItem.FolderNo = gf.GetDataInt(rs, "FolderNo");
				InItem.Copyright = gf.GetDataString(rs, "Copyright");
				InItem.Show_LicAdminInfo1 = gf.GetDataString(rs, "LICENCE_ADMIN1");
				InItem.Show_LicAdminInfo2 = gf.GetDataString(rs, "LICENCE_ADMIN2");
				InItem.Format.FormatString = gf.GetDataString(rs, "FORMATDATA");
				InItem.Notations = gf.GetDataString(rs, "msc");
				InItem.Capo = gf.GetDataInt(rs, "capo", true);
				InItem.SongSequence = gf.GetDataString(rs, "Sequence");
				InItem.Writer = gf.GetDataString(rs, "Writer");
				InItem.Book_Reference = gf.GetDataString(rs, "Book_Reference");
				InItem.User_Reference = gf.GetDataString(rs, "User_Reference");
				InItem.Timing = gf.GetDataString(rs, "timing");
				InItem.MusicKey = gf.GetDataString(rs, "key");
				InItem.Category = gf.GetDataString(rs, "category");
				InItem.Settings = gf.GetDataString(rs, "SETTINGS");
				result = true;
				return result;
			}
			catch
			{
			}
			result = false;
			return result;
		}
		public static void ResetPictureBox(ref gf.SongSettings InItem, ref ImageTransitionControl InScreen, gf.GapType GapItemBackground, ImageTransitionControl.TransitionAction InTransAction)
		{
			Color color = InItem.Format.ShowScreenColour[0];
			Color color2 = InItem.Format.ShowScreenColour[1];
			int showScreenStyle = InItem.Format.ShowScreenStyle;
			string tempImageFileName = InItem.Format.TempImageFileName;
			string backgroundPicture = InItem.Format.BackgroundPicture;
			int backgroundMode = (int)InItem.Format.BackgroundMode;
			bool useDefaultFormat = InItem.UseDefaultFormat;
			string text = InItem.Lyrics[0].Text;
			string text2 = InItem.Lyrics[1].Text;
			string text3 = InItem.Lyrics[2].Text;
			string songSequence = InItem.SongSequence;
			InItem.SongSequence = "";
			InItem.Lyrics[0].Text = "";
			InItem.Lyrics[1].Text = "";
			InItem.Lyrics[2].Text = "";
			InItem.Format.BackgroundPicture = "";
			InItem.Format.MediaLocation = "";
			if (InTransAction != ImageTransitionControl.TransitionAction.AsStored)
			{
				InItem.Format.ShowSlideTransition = 0;
			}
			if (InItem.OutputStyleScreen)
			{
				switch (GapItemBackground)
				{
				case gf.GapType.Black:
					InItem.UseDefaultFormat = false;
					InItem.Format.ShowScreenColour[0] = gf.BlackScreenColour;
					InItem.Format.ShowScreenColour[1] = gf.BlackScreenColour;
					InItem.Format.ShowScreenStyle = 11;
					InItem.Format.TempImageFileName = "";
					InItem.Format.BackgroundPicture = "";
					InItem.Format.ShowSlideTransition = (gf.GapItemUseFade ? 15 : 0);
					break;
				case gf.GapType.Default:
					InItem.UseDefaultFormat = false;
					InItem.Format.ShowScreenColour[0] = gf.ShowScreenColour[0];
					InItem.Format.ShowScreenColour[1] = gf.ShowScreenColour[1];
					InItem.Format.ShowScreenStyle = gf.ShowScreenStyle;
					InItem.Format.TempImageFileName = gf.BackgroundPicture;
					InItem.Format.BackgroundPicture = gf.BackgroundPicture;
					InItem.Format.BackgroundMode = gf.BackgroundMode;
					InItem.Format.ShowSlideTransition = (gf.GapItemUseFade ? 15 : 0);
					break;
				case gf.GapType.User:
				{
					InItem.UseDefaultFormat = false;
					InItem.Format.TempImageFileName = gf.GapItemLogoFile;
					InItem.Format.BackgroundPicture = gf.GapItemLogoFile;
					string directoryName = Path.GetDirectoryName(InItem.Format.BackgroundPicture);
					if (directoryName == gf.RootEasiSlidesDir + "Images\\Tiles")
					{
						InItem.Format.BackgroundMode = gf.ImageMode.Tile;
					}
					else
					{
						InItem.Format.BackgroundMode = gf.ImageMode.BestFit;
					}
					InItem.Format.ShowSlideTransition = (gf.GapItemUseFade ? 15 : 0);
					break;
				}
				}
			}
			gf.SetShowBackground(InItem, ref InScreen, false);
			InItem.UseDefaultFormat = useDefaultFormat;
			InItem.Format.ShowScreenColour[0] = color;
			InItem.Format.ShowScreenColour[1] = color2;
			InItem.Format.ShowScreenStyle = showScreenStyle;
			InItem.Format.BackgroundPicture = backgroundPicture;
			InItem.Format.TempImageFileName = tempImageFileName;
			InItem.Format.BackgroundMode = (gf.ImageMode)backgroundMode;
			gf.DrawText(ref InItem, ref InScreen, InItem.LyricsAndNotationsList, false, true);
		}
		public static string LookUpMediaString(DShowLib Player)
		{
			string result;
			switch (gf.LookUpMediaInteger(Player))
			{
			case 1:
				result = "Audio Only";
				break;
			case 2:
				result = "Video";
				break;
			default:
				result = "No Media Playing";
				break;
			}
			return result;
		}
		public static string LookUpMediaString(DShowLib Player, int InCode, int WaitCount)
		{
			string result;
			switch (InCode)
			{
			case -1:
				result = "Selected Source Not Playable";
				break;
			case 0:
			{
				WaitCount /= 3;
				string text = "";
				for (int i = 0; i < WaitCount; i++)
				{
					text += ".";
				}
				result = "Connecting to media..." + text;
				break;
			}
			default:
				result = "No Media Playing";
				break;
			}
			return result;
		}
		public static int LookUpMediaInteger(DShowLib Player)
		{
			int result;
			try
			{
				if (Player.newFilename != "")
				{
					if (Player.isVideo)
					{
						result = 1;
					}
					else
					{
						result = 2;
					}
				}
				else
				{
					result = 3;
				}
			}
			catch
			{
				result = 3;
			}
			return result;
		}
		public static string GetMediaLocation(gf.SongSettings InItem)
		{
			return gf.GetMediaLocation(InItem.Format.MediaOption, InItem.Title, InItem.Title2, InItem.UseDefaultFormat, InItem.Type, InItem.Format.MediaLocation, InItem.Format.MediaCaptureDeviceNumber);
		}
		public static string GetMediaLocation(int InMediaOption, string InTitle1, string InTitle2, bool InUseDefaultFormat, string InType, string InMediaLocation, int InMediaCaptureDeviceNumber)
		{
			InMediaOption = ((InUseDefaultFormat && InType != "M") ? gf.MediaOption : InMediaOption);
			string result;
			switch (InMediaOption)
			{
			case 1:
				result = gf.GetMediaFileName(InTitle1, InTitle2);
				break;
			case 2:
				result = ((InUseDefaultFormat && InType != "M") ? gf.MediaLocation : InMediaLocation);
				break;
			case 3:
				result = "<<Capture>>" + (InUseDefaultFormat ? gf.MediaCaptureDeviceNumber.ToString() : InMediaCaptureDeviceNumber.ToString());
				break;
			default:
				result = "";
				break;
			}
			return result;
		}
		public static string OldGetMediaLocation(gf.SongSettings InItem)
		{
			string result;
			switch (InItem.Format.MediaOption)
			{
			case 1:
				result = gf.GetMediaFileName(InItem.Title, InItem.Title2);
				break;
			case 2:
				result = ((InItem.UseDefaultFormat && InItem.Type != "M") ? gf.MediaLocation : InItem.Format.MediaLocation);
				break;
			case 3:
				result = "<<Capture>>" + InItem.Format.MediaCaptureDeviceNumber.ToString();
				break;
			default:
				result = "";
				break;
			}
			return result;
		}
		public static void GetRotationStyle(ref gf.SongSettings InItem)
		{
			string text = InItem.RotateString;
			string a = "";
			string a2 = "";
			string[] array = text.Split(new char[]
			{
				"»"[0]
			});
			if (array.GetUpperBound(0) >= 0)
			{
				text = array[0];
				if (array.GetUpperBound(0) >= 1)
				{
					a = array[1];
				}
			}
			int num = gf.StringToInt(gf.ExtractOneInfo(ref text, ';', true, false));
			if (num < 1 || num > 2)
			{
				num = 1;
			}
			InItem.RotateStyle = num;
			int num2 = gf.StringToInt(gf.ExtractOneInfo(ref text, ';', true, false));
			if (num2 < 0 || num2 > 99999)
			{
				num2 = 0;
			}
			InItem.RotateGap = num2;
			int num3 = gf.StringToInt(gf.ExtractOneInfo(ref text, ';', true, false));
			if (num3 < 0 || num3 > 3599)
			{
				num3 = 0;
			}
			InItem.RotateTotal = num3;
			a2 = text;
			InItem.RotateTimings = "";
			InItem.RotateSequence = "";
			while (a2 != "")
			{
				num2 = gf.StringToInt(gf.ExtractOneInfo(ref a2, ';', true, true));
				if ((num2 >= 0 && num2 < 99) || (num2 >= 100 && num2 < 112))
				{
					gf.SongSettings expr_15B = InItem;
					expr_15B.RotateSequence += ((char)num2).ToString();
				}
			}
			int num4 = num;
			if (num4 == 2)
			{
				ListBox listBox = new ListBox();
				listBox.Sorted = false;
				while (a != "")
				{
					num2 = gf.StringToInt(gf.ExtractOneInfo(ref a, ';', true, true));
					if (num2 > 0 && num2 <= 99999)
					{
						listBox.Items.Add(num2.ToString("00000"));
					}
				}
				if (listBox.Items.Count > 0)
				{
					listBox.Sorted = true;
					for (int i = 0; i < listBox.Items.Count; i++)
					{
						string arg = gf.StringToInt(listBox.Items[i].ToString()).ToString();
						gf.SongSettings expr_255 = InItem;
						expr_255.RotateTimings = expr_255.RotateTimings + arg + ';';
					}
				}
			}
		}
		public static void LoadReferenceAlert(ref ImageTransitionControl InScreen, gf.SongSettings InItem, bool ClearAll, bool DoActiveIndicator)
		{
			InScreen.StopRef();
			string text = "";
			if (!ClearAll)
			{
				switch (gf.ReferenceAlertSource)
				{
				case 1:
					text = InItem.Title;
					break;
				case 2:
					text = InItem.SongNumber.ToString();
					break;
				case 3:
					text = InItem.Book_Reference;
					break;
				case 4:
					text = InItem.User_Reference;
					break;
				default:
					text = "";
					break;
				}
			}
			if (gf.ReferenceAlertUsePick & text != "" & gf.ReferenceAlertPickName != "")
			{
				int num = text.IndexOf(gf.ReferenceAlertPickName);
				if (num >= 0)
				{
					int num2 = num + gf.ReferenceAlertPickName.Length;
					if (text.Length == num2)
					{
						text = gf.ReferenceAlertPickSubstitute;
					}
					else
					{
						if (gf.ReferenceAlertPickSeparator != "")
						{
							int num3 = text.IndexOfAny(gf.ReferenceAlertPickSeparator.ToCharArray(), num2);
							num3 = ((num3 >= 0) ? num3 : text.Length);
							text = ((gf.ReferenceAlertPickSubstitute == "") ? gf.ReferenceAlertPickName : gf.ReferenceAlertPickSubstitute) + gf.Mid(text, num2, num3 - num2);
						}
						else
						{
							text = ((gf.ReferenceAlertPickSubstitute == "") ? gf.ReferenceAlertPickName : gf.ReferenceAlertPickSubstitute) + gf.Mid(text, num2, text.Length - num2);
						}
					}
				}
				else
				{
					if (gf.ReferenceAlertBlankIfPickNotFound)
					{
						text = "";
					}
				}
			}
			if (DoActiveIndicator && text == "")
			{
				text = " ";
			}
			if (text == "")
			{
				InScreen.StopRef();
				InScreen.RefDisplayString = "";
			}
			else
			{
				gf.ReferenceAlertFont = gf.GetNewFont(gf.ReferenceAlertFontName, gf.ReferenceAlertFontSize, gf.ReferenceAlertBold, gf.ReferenceAlertItalic, gf.ReferenceAlertUnderline, false);
				InScreen.LoadRef(InItem, gf.Left(text, 50), gf.ReferenceAlertDuration, gf.ReferenceAlertFont, gf.ReferenceAlertScroll, gf.ReferenceAlertFlash, gf.ReferenceAlertTransparent, gf.ReferenceAlertShadow, gf.ReferenceAlertOutline, gf.ReferenceAlertTextColour, gf.ReferenceAlertBackColour, gf.ReferenceAlertTextAlign, gf.ReferenceAlertVerticalAlign, gf.BottomBorderFactor);
			}
		}
		public static void DeleteFolderFiles(string InFolder)
		{
			try
			{
				string[] files = Directory.GetFiles(InFolder);
				string[] array = files;
				for (int i = 0; i < array.Length; i++)
				{
					string path = array[i];
					try
					{
						File.Delete(path);
					}
					catch
					{
					}
				}
				string[] directories = Directory.GetDirectories(InFolder);
				array = directories;
				for (int i = 0; i < array.Length; i++)
				{
					string text = array[i];
					try
					{
						gf.DeleteFolderFiles(text);
						Directory.Delete(text);
					}
					catch
					{
					}
				}
			}
			catch
			{
			}
		}
		internal static int GetNextNonRotateItem(bool CurrentItemIsGapItem)
		{
			int startPresAt = gf.StartPresAt;
			int startPresAt2 = gf.StartPresAt;
			int num = -1;
			int num2 = -1;
			int result;
			if (gf.TotalWorshipListItems > 0)
			{
				int i = startPresAt2 + 1;
				for (i = startPresAt2 + 1; i <= gf.TotalWorshipListItems; i++)
				{
					int itemRotateResult = gf.GetItemRotateResult(gf.TempItem2, gf.WorshipSongs[i, 0]);
					if (itemRotateResult < 1)
					{
						if (num < 0)
						{
							num = i;
						}
						else
						{
							if (num2 < 0)
							{
								num2 = i;
							}
						}
						if (num2 > 0)
						{
							i = gf.TotalWorshipListItems;
						}
					}
				}
				if (num > 0)
				{
					if (gf.GapItemOption == gf.GapType.None)
					{
						result = num;
						return result;
					}
					if (!CurrentItemIsGapItem)
					{
						result = num - 1;
						return result;
					}
					if (num == startPresAt2 + 1)
					{
						result = num;
						return result;
					}
					result = num - 1;
					return result;
				}
			}
			result = startPresAt;
			return result;
		}
		internal static int GetItemRotateResult(string InIDString)
		{
			return gf.GetItemRotateResult(gf.TempItem1, InIDString);
		}
		internal static int GetItemRotateResult(gf.SongSettings InItem, string InIDString)
		{
			string a = gf.Left(InIDString, 1);
			int result;
			if (a == "I" | a == "D")
			{
				string text = "";
				gf.LoadIndividualData(ref InItem, InIDString, "", 1, ref text);
				gf.MediaBackgroundStyle mediaBackgroundType = gf.GetMediaBackgroundType(InItem, false);
				switch (InItem.RotateStyle)
				{
				case 1:
					if (InItem.RotateGap > 0)
					{
						result = ((mediaBackgroundType == gf.MediaBackgroundStyle.Video || mediaBackgroundType == gf.MediaBackgroundStyle.SameAsPrevious) ? 2 : 1);
						return result;
					}
					break;
				case 2:
					if (InItem.RotateTimings != "" || InItem.RotateTotal > 0)
					{
						result = ((mediaBackgroundType == gf.MediaBackgroundStyle.Video || mediaBackgroundType == gf.MediaBackgroundStyle.SameAsPrevious) ? 2 : 1);
						return result;
					}
					break;
				}
			}
			result = 0;
			return result;
		}
		public static gf.MediaBackgroundStyle GetMediaBackgroundType(gf.SongSettings InItem, bool UpdateVariables)
		{
			string mediaLocation = gf.GetMediaLocation(InItem);
			gf.MediaBackgroundStyle result;
			if (mediaLocation == "")
			{
				if (UpdateVariables)
				{
					gf.CurrentMediaLocation = "";
				}
				result = gf.MediaBackgroundStyle.None;
			}
			else
			{
				if (mediaLocation == gf.CurrentMediaLocation)
				{
					result = gf.MediaBackgroundStyle.SameAsPrevious;
				}
				else
				{
					gf.MediaBackgroundStyle mediaType = gf.GetMediaType(mediaLocation);
					if (UpdateVariables)
					{
						gf.CurrentMediaLocation = mediaLocation;
						gf.CurrentMediaIsVideo = (mediaType == gf.MediaBackgroundStyle.Video);
					}
					result = mediaType;
				}
			}
			return result;
		}
		public static gf.MediaBackgroundStyle GetMediaType(string InLocation)
		{
			gf.MediaBackgroundStyle result;
			if (gf.Left(InLocation, "<<Capture>>".Length) == "<<Capture>>")
			{
				result = gf.MediaBackgroundStyle.Video;
			}
			else
			{
				string b = "";
				try
				{
					b = Path.GetExtension(InLocation).ToLower();
				}
				catch
				{
					result = gf.MediaBackgroundStyle.Audio;
					return result;
				}
				int i = 0;
				while (i < gf.TotalMediaFileExt)
				{
					if (gf.MediaFileExtension[i, 0] == b)
					{
						if (gf.MediaFileExtension[i, 1] == gf.MediaBackgroundStyle.Video.ToString())
						{
							result = gf.MediaBackgroundStyle.Video;
							return result;
						}
						result = gf.MediaBackgroundStyle.Audio;
						return result;
					}
					else
					{
						i++;
					}
				}
				result = gf.MediaBackgroundStyle.Audio;
			}
			return result;
		}
		public static void SubDivideTextAndNotations(string InString, string InNotation, Font MainFont, Font NotationsFont, ref ListView TextNotationsList, int InWidth)
		{
			InWidth /= 15;
			Graphics graphics = TextNotationsList.CreateGraphics();
			ListViewItem listViewItem = new ListViewItem();
			int num = 0;
			TextNotationsList.Items.Clear();
			while (InString != "")
			{
				int length = InString.Length;
				for (int i = length; i >= 1; i--)
				{
					string text = gf.Left(InString, i);
					if (graphics.MeasureString(text, MainFont, 32000, StringFormat.GenericDefault).Width <= (float)InWidth | text.IndexOf(" ") < 0)
					{
						if (gf.Right(text, 1) == " " | i == length | text.IndexOf(" ") < 0)
						{
							listViewItem = TextNotationsList.Items.Add(text);
							listViewItem.SubItems.Add("");
							string a = InNotation;
							string text2 = "";
							while (a != "")
							{
								string text3 = gf.ExtractOneInfo(ref a, ';');
								string text4 = gf.ExtractOneInfo(ref a, ';');
								if (text3 != "-1" & text4 != "-1")
								{
									if (Convert.ToInt32(text4) >= num)
									{
										if (Convert.ToInt32(text4) >= num + i & i < length)
										{
											a = "";
										}
										else
										{
											object obj = text2;
											text2 = string.Concat(new object[]
											{
												obj,
												text3,
												';',
												Convert.ToString(Convert.ToInt32(text4) - num),
												';'
											});
										}
									}
								}
							}
							listViewItem.SubItems.Add((text2 != "") ? text2 : " ");
							listViewItem.SubItems.Add(Convert.ToString(num));
							num += i;
							InString = gf.Mid(InString, i);
							i = 0;
						}
					}
				}
			}
			for (int i = 0; i < TextNotationsList.Items.Count; i++)
			{
				TextNotationsList.Items[i].SubItems[1].Text = gf.FormatNotationString(TextNotationsList, TextNotationsList.Items[i].SubItems[0].Text, TextNotationsList.Items[i].SubItems[2].Text, MainFont, NotationsFont);
			}
		}
		public static void OldSubDivideTextAndNotations(string InString, string InNotation, Font MainFont, Font NotationsFont, ref ListView TextNotationsList, int InWidth)
		{
			InWidth /= 15;
			Graphics graphics = TextNotationsList.CreateGraphics();
			ListViewItem listViewItem = new ListViewItem();
			int num = 0;
			TextNotationsList.Items.Clear();
			while (InString != "")
			{
				int length = InString.Length;
				for (int i = length; i >= 1; i--)
				{
					string text = gf.Left(InString, i);
					if (graphics.MeasureString(text, MainFont, 32000, StringFormat.GenericDefault).Width <= (float)InWidth | text.IndexOf(" ") < 0)
					{
						if (gf.Right(text, 1) == " " | i == length | text.IndexOf(" ") < 0)
						{
							listViewItem = TextNotationsList.Items.Add(text);
							listViewItem.SubItems.Add("");
							string a = InNotation;
							string text2 = "";
							while (a != "")
							{
								string text3 = gf.ExtractOneInfo(ref a, ';');
								string text4 = gf.ExtractOneInfo(ref a, ';');
								if (text3 != "-1" & text4 != "-1")
								{
									if (Convert.ToInt32(text4) >= num)
									{
										if (Convert.ToInt32(text4) >= num + i & i < length)
										{
											a = "";
										}
										else
										{
											object obj = text2;
											text2 = string.Concat(new object[]
											{
												obj,
												text3,
												';',
												Convert.ToString(Convert.ToInt32(text4) - num),
												';'
											});
										}
									}
								}
							}
							listViewItem.SubItems.Add((text2 != "") ? text2 : " ");
							listViewItem.SubItems.Add(Convert.ToString(num));
							num += i;
							InString = gf.Mid(InString, i);
							i = 0;
						}
					}
				}
			}
			for (int i = 0; i < TextNotationsList.Items.Count; i++)
			{
			}
		}
		public static void SetLiveShowScreenSaverSettings()
		{
			gf.SystemParametersInfo(16, 0, ref gf.PriorScreenSaverState, 0);
			if (gf.PriorScreenSaverState && gf.DisableSreenSaver)
			{
				gf.SetScreenSaverActive(false);
			}
		}
		public static void RestoreScreenSaverSettings()
		{
			if (gf.PriorScreenSaverState)
			{
				gf.SetScreenSaverActive(true);
			}
		}
		public static void SetScreenSaverActive(bool SetOn)
		{
			gf.SystemParametersInfo(17, SetOn ? 1 : 0, ref SetOn, 0);
		}
		public static void HighlightDisplaySlidesText(gf.SongSettings InItem, ref RichTextBox InTextBox)
		{
			gf.HighlightDisplaySlidesText(InItem, ref InTextBox, true);
		}
		public static void HighlightDisplaySlidesText(gf.SongSettings InItem, ref RichTextBox InTextBox, bool ScrollToCaret)
		{
			gf.HighlightDisplaySlidesText(InItem, ref InTextBox, ScrollToCaret, gf.BlackScreenColour, Color.Red);
		}
		public static void HighlightDisplaySlidesText(gf.SongSettings InItem, ref RichTextBox InTextBox, bool ScrollToCaret, Color TextColour, Color HighlightColour)
		{
			InItem.CurSlide = ((InItem.CurSlide < 1) ? 1 : ((InItem.CurSlide > InItem.TotalSlides) ? InItem.TotalSlides : InItem.CurSlide));
			InTextBox.Select(0, InTextBox.Text.Length);
			InTextBox.SelectionColor = TextColour;
			InTextBox.Select(InItem.Slide[InItem.CurSlide, 5], InItem.Slide[InItem.CurSlide, 6]);
			InTextBox.SelectionColor = HighlightColour;
			InTextBox.SelectionLength = 0;
			if (ScrollToCaret)
			{
				InTextBox.Select(InItem.Slide[InItem.CurSlide, 5] + InItem.Slide[InItem.CurSlide, 6] + 90, 0);
				InTextBox.ScrollToCaret();
				InTextBox.Select(InItem.Slide[InItem.CurSlide, 5], 0);
				InTextBox.ScrollToCaret();
			}
		}
		public static void DisplaySlidesFormattedLyrics(ref gf.SongSettings InItem, ref RichTextBox PInTextBox, ref RichTextBox OInTextBox, bool ScrollToCaret, bool PreviewNotations)
		{
			if (InItem.OutputStyleScreen)
			{
				gf.DisplaySlidesFormattedLyrics(ref InItem, ref OInTextBox, ScrollToCaret, PreviewNotations);
			}
			else
			{
				gf.DisplaySlidesFormattedLyrics(ref InItem, ref PInTextBox, ScrollToCaret, PreviewNotations);
			}
		}
		public static void DisplaySlidesFormattedLyrics(ref gf.SongSettings InItem, ref RichTextBox InTextBox, bool ScrollToCaret, bool PreviewNotations)
		{
			InItem.CurSlide = ((InItem.CurSlide < 1) ? 1 : ((InItem.CurSlide > InItem.TotalSlides) ? InItem.TotalSlides : InItem.CurSlide));
			InItem.FolderNo = ((InItem.FolderNo > 0) ? InItem.FolderNo : 1);
			InTextBox.Text = "";
			if (!(InItem.Type == "P"))
			{
				int num = 0;
				for (int i = 1; i <= InItem.TotalSlides; i++)
				{
					num = InTextBox.Text.Length;
					int num2 = 0;
					try
					{
						if (InItem.Slide[i, 0] >= 0)
						{
							if (i > 1)
							{
								RichTextBox expr_CC = InTextBox;
								expr_CC.Text += "\n";
							}
							if (InItem.Slide[i, 0] == 0)
							{
								RichTextBox expr_101 = InTextBox;
								expr_101.Text += ((gf.FolderLyricsHeading[InItem.FolderNo, 1] != "") ? gf.FolderLyricsHeading[InItem.FolderNo, 1] : "Chorus:");
							}
							else
							{
								if (InItem.Slide[i, 0] == 102)
								{
									RichTextBox expr_16E = InTextBox;
									expr_16E.Text += ((gf.FolderLyricsHeading[InItem.FolderNo, 1] != "") ? (gf.FolderLyricsHeading[InItem.FolderNo, 1] + " (2)") : "Chorus 2:");
								}
								else
								{
									if (InItem.Slide[i, 0] == 111)
									{
										RichTextBox expr_1E5 = InTextBox;
										expr_1E5.Text += ((gf.FolderLyricsHeading[InItem.FolderNo, 0] != "") ? gf.FolderLyricsHeading[InItem.FolderNo, 0] : "Prechorus:");
									}
									else
									{
										if (InItem.Slide[i, 0] == 112)
										{
											RichTextBox expr_252 = InTextBox;
											expr_252.Text += ((gf.FolderLyricsHeading[InItem.FolderNo, 0] != "") ? (gf.FolderLyricsHeading[InItem.FolderNo, 0] + " (2)") : "Prechorus 2:");
										}
										else
										{
											if (InItem.Slide[i, 0] == 100)
											{
												RichTextBox expr_2C9 = InTextBox;
												expr_2C9.Text += ((gf.FolderLyricsHeading[InItem.FolderNo, 2] != "") ? gf.FolderLyricsHeading[InItem.FolderNo, 2] : "Bridge:");
											}
											else
											{
												if (InItem.Slide[i, 0] == 103)
												{
													RichTextBox expr_336 = InTextBox;
													expr_336.Text += ((gf.FolderLyricsHeading[InItem.FolderNo, 2] != "") ? (gf.FolderLyricsHeading[InItem.FolderNo, 2] + " (2)") : "Bridge 2:");
												}
												else
												{
													if (InItem.Slide[i, 0] == 101)
													{
														RichTextBox expr_3AD = InTextBox;
														expr_3AD.Text += ((gf.FolderLyricsHeading[InItem.FolderNo, 3] != "") ? gf.FolderLyricsHeading[InItem.FolderNo, 3] : "Ending:");
													}
													else
													{
														if (InItem.Verse2Present || (i > 1 && InItem.Slide[i, 0] == 1))
														{
															RichTextBox expr_42B = InTextBox;
															expr_42B.Text = expr_42B.Text + gf.VerseTitle[InItem.Slide[i, 0]] + ".";
															int num3 = InItem.Slide[i, 0];
														}
													}
												}
											}
										}
									}
								}
							}
							num2 = InTextBox.Text.Length - num;
						}
					}
					catch
					{
						MessageBox.Show("Error");
					}
					RichTextBox expr_48F = InTextBox;
					expr_48F.Text += "\n";
					if (InItem.Slide[i, 2] >= 0)
					{
						RichTextBox expr_4C0 = InTextBox;
						expr_4C0.Text += gf.GetSlideContents(InItem, i, 0, InTextBox.Font, PreviewNotations);
					}
					if (InItem.Slide[i, 4] >= 0)
					{
						RichTextBox expr_4FF = InTextBox;
						expr_4FF.Text += gf.GetSlideContents(InItem, i, 1, InTextBox.Font, PreviewNotations);
					}
					int num4 = InTextBox.Text.Length - num + 1;
					InItem.Slide[i, 5] = num;
					InItem.Slide[i, 6] = num4;
					InItem.Slide[i, 7] = num2;
				}
				for (int i = 1; i <= InItem.TotalSlides; i++)
				{
					if (InItem.Slide[InItem.CurSlide, 7] > 0)
					{
						InTextBox.Select(InItem.Slide[i, 5], InItem.Slide[i, 7]);
						InTextBox.SelectionFont = new Font(InTextBox.Font, FontStyle.Regular);
						InTextBox.SelectionLength = 0;
					}
				}
				gf.HighlightDisplaySlidesText(InItem, ref InTextBox, ScrollToCaret);
			}
		}
		public static void DisplayRichTextBoxSeries(ref gf.SongSettings InItem, ref Panel InPanel, ref RichTextBox[] InRichTextBox, bool ScrollToCaret, bool PreviewNotations)
		{
			InItem.CurSlide = ((InItem.CurSlide < 1) ? 1 : ((InItem.CurSlide > InItem.TotalSlides) ? InItem.TotalSlides : InItem.CurSlide));
			InItem.FolderNo = ((InItem.FolderNo > 0) ? InItem.FolderNo : 1);
			if (InRichTextBox[1] != null && !(InItem.Type == "P"))
			{
				int num = 0;
				string text = "";
				for (int i = 1; i <= InItem.TotalSlides; i++)
				{
					text = "";
					num = text.Length;
					int num2 = 0;
					try
					{
						if (InItem.Slide[i, 0] >= 0)
						{
							if (i > 1)
							{
								text += "\n";
							}
							if (InItem.Slide[i, 0] == 0)
							{
								text += ((gf.FolderLyricsHeading[InItem.FolderNo, 1] != "") ? gf.FolderLyricsHeading[InItem.FolderNo, 1] : "Chorus:");
							}
							else
							{
								if (InItem.Slide[i, 0] == 102)
								{
									text += ((gf.FolderLyricsHeading[InItem.FolderNo, 1] != "") ? (gf.FolderLyricsHeading[InItem.FolderNo, 1] + " (2)") : "Chorus 2:");
								}
								else
								{
									if (InItem.Slide[i, 0] == 111)
									{
										text += ((gf.FolderLyricsHeading[InItem.FolderNo, 0] != "") ? gf.FolderLyricsHeading[InItem.FolderNo, 0] : "Prechorus:");
									}
									else
									{
										if (InItem.Slide[i, 0] == 112)
										{
											text += ((gf.FolderLyricsHeading[InItem.FolderNo, 0] != "") ? (gf.FolderLyricsHeading[InItem.FolderNo, 0] + " (2)") : "Prechorus 2:");
										}
										else
										{
											if (InItem.Slide[i, 0] == 100)
											{
												text += ((gf.FolderLyricsHeading[InItem.FolderNo, 2] != "") ? gf.FolderLyricsHeading[InItem.FolderNo, 2] : "Bridge:");
											}
											else
											{
												if (InItem.Slide[i, 0] == 103)
												{
													text += ((gf.FolderLyricsHeading[InItem.FolderNo, 2] != "") ? (gf.FolderLyricsHeading[InItem.FolderNo, 2] + " (2)") : "Bridge 2:");
												}
												else
												{
													if (InItem.Slide[i, 0] == 101)
													{
														text += ((gf.FolderLyricsHeading[InItem.FolderNo, 3] != "") ? gf.FolderLyricsHeading[InItem.FolderNo, 3] : "Ending:");
													}
													else
													{
														if (InItem.Verse2Present || (i > 1 && InItem.Slide[i, 0] == 1))
														{
															text = text + gf.VerseTitle[InItem.Slide[i, 0]] + ".";
															int num3 = InItem.Slide[i, 0];
														}
													}
												}
											}
										}
									}
								}
							}
							num2 = text.Length - num;
						}
					}
					catch
					{
						MessageBox.Show("Error");
					}
					text += "\n";
					if (InItem.Slide[i, 2] >= 0)
					{
						text += gf.GetSlideContents(InItem, i, 0, InRichTextBox[1].Font, PreviewNotations);
					}
					if (InItem.Slide[i, 4] >= 0)
					{
						text += gf.GetSlideContents(InItem, i, 1, InRichTextBox[1].Font, PreviewNotations);
					}
					text = gf.TrimStart(text);
					text = gf.TrimEnd(text);
					if (InRichTextBox[i] != null)
					{
						InRichTextBox[i].Text = text;
						InRichTextBox[i].SelectAll();
						InRichTextBox[i].SelectionFont = new Font("Microsoft Sans Serif", InRichTextBox[i].Font.Size, InRichTextBox[i].Font.Style);
						InRichTextBox[i].SelectionStart = 0;
						InRichTextBox[i].SelectionLength = 0;
					}
					int num4 = text.Length - num + 1;
					InItem.Slide[i, 5] = num;
					InItem.Slide[i, 6] = num4;
					InItem.Slide[i, 7] = num2;
				}
				//gf.HighlightRichTextBox(ref InRichTextBox, ref InPanel, InItem, false, ScrollToCaret);
			}
		}
		public static void RefreshWindowsDesktop()
		{
			gf.InvalidateRect(IntPtr.Zero, IntPtr.Zero, true);
		}
		public static void BuildSubFolderList(string InDir, string RemovePrefix, ref string[,] InGroup, ref int InTotal)
		{
			string[] directories = Directory.GetDirectories(InDir);
			if (directories.Length > 0)
			{
				gf.SingleArraySort(directories);
			}
			string[] array = directories;
			for (int i = 0; i < array.Length; i++)
			{
				string text = array[i];
				if ((!(RemovePrefix == gf.ImagesDir) || !(text == gf.RootEasiSlidesDir + "Images\\Scenery")) && !(text == gf.RootEasiSlidesDir + "Images\\Tiles"))
				{
					if (InTotal < 255)
					{
						InGroup[InTotal, 1] = text + "\\";
						InGroup[InTotal, 0] = "\\" + text.Replace(RemovePrefix, "");
						InTotal++;
						gf.BuildSubFolderList(text, RemovePrefix, ref InGroup, ref InTotal);
					}
				}
			}
		}
		public static void ClipboardCopyTextBox(RichTextBox InTextBox)
		{
			if (InTextBox.SelectedText != "")
			{
				Clipboard.SetDataObject(InTextBox.SelectedText);
			}
			else
			{
				Clipboard.SetDataObject("");
			}
		}
		public static void ClipboardPasteTextBox(RichTextBox InTextBox, int Location)
		{
			InTextBox.SelectionLength = 0;
			InTextBox.SelectionStart = Location;
			InTextBox.Focus();
			InTextBox.Paste();
		}
		public static void ClipboardPasteTextBox(RichTextBox InTextBox, int Location, string InPasteString)
		{
			Clipboard.SetDataObject(InPasteString.Replace("\r\n", "\n").Replace("\r", "\n").Replace("\v", "\n"));
			InTextBox.SelectionLength = 0;
			InTextBox.SelectionStart = Location;
			InTextBox.Focus();
			InTextBox.Paste();
		}
		public static void InsertIndicator(ref RichTextBox InTextBox, int InNum)
		{
			int selectionStart = InTextBox.SelectionStart;
			string selectedText = (InNum == 152) ? " »" : gf.VerseSymbol[InNum];
			string text = "";
			if (InNum == 151)
			{
				gf.GetCurPosInLine(InTextBox.Text, ref selectionStart);
				InTextBox.SelectionStart = selectionStart;
			}
			else
			{
				if (InNum == 152)
				{
					gf.MoveToPosInLine(InTextBox.Text, ref selectionStart, 1);
					InTextBox.SelectionStart = selectionStart;
				}
				else
				{
					gf.GetCurPosInLine(InTextBox.Text, ref selectionStart);
					InTextBox.SelectionStart = selectionStart;
					text = ((gf.Mid(InTextBox.Text, selectionStart, 1) == "\r" | gf.Mid(InTextBox.Text, selectionStart, 1) == "\n") ? "" : "\r\n");
				}
			}
			InTextBox.SelectedText = selectedText;
			if (text != "")
			{
				InTextBox.SelectedText = text;
			}
			if (InNum == 152)
			{
				InTextBox.SelectionStart--;
			}
		}
		public static void LoadBlankCaptureDevices(ref ToolStripComboBox InComboBoxDevice, ref ToolStripComboBox InComboBoxMedium)
		{
			InComboBoxDevice.Items.Clear();
			for (int i = 1; i <= 10; i++)
			{
				InComboBoxDevice.Items.Add(i.ToString() + ".");
			}
			InComboBoxMedium.Items.Clear();
			InComboBoxMedium.Items.Add("Video");
		}
		public static void LoadBlankCaptureDevices(ref ToolStripComboBox InComboBoxDevice)
		{
			InComboBoxDevice.Items.Clear();
			for (int i = 1; i <= 10; i++)
			{
				InComboBoxDevice.Items.Add(i.ToString() + ".");
			}
		}
		public static void HighlightRichTextBox(ref RichTextBox[] InRichTextBox, ref Panel InPanel, gf.SongSettings InItem, bool OnEnterPanel, bool ScrollToTop)
		{
			if (OnEnterPanel)
			{
				gf.Control_Enter(InPanel);
			}
			else
			{
				gf.Control_Leave(InPanel);
			}
			for (int i = 1; i <= InItem.TotalSlides; i++)
			{
				if (InRichTextBox[i] != null)
				{
					if (OnEnterPanel)
					{
						gf.Control_Enter(InRichTextBox[i]);
						if ((string)InRichTextBox[i].Tag == InItem.CurSlide.ToString() && !InItem.GapItemOnDisplay)
						{
							InRichTextBox[i].ForeColor = gf.TextRegionSlideTextColour;
                            InRichTextBox[i].BackColor = gf.TextRegionSlideBackColour;
							int top = InRichTextBox[i].Top;
							int num = top;
							if (ScrollToTop)
							{
								bool flag = top <= 0;
								while (!flag)
								{
									gf.SendMessage(InPanel.Handle, 277u, 3u, 0u);
									top = InRichTextBox[i].Top;
									if (top < num && top > 0)
									{
										num = top;
									}
									else
									{
										flag = true;
									}
								}
							}
							InRichTextBox[i].Focus();
							InPanel.ScrollControlIntoView(InRichTextBox[i]);
							if (!ScrollToTop && i < InItem.TotalSlides)
							{
								top = InRichTextBox[i].Top;
								int num2 = 0;
								while (top > 5 && num2 < 5)
								{
									gf.SendMessage(InPanel.Handle, 277u, 1u, 0u);
									top = InRichTextBox[i].Top;
									num2++;
								}
							}
						}
						else
						{
							InRichTextBox[i].ForeColor = gf.NormalTextColour;
						}
					}
					else
					{
						gf.Control_Leave(InRichTextBox[i]);
						if ((string)InRichTextBox[i].Tag == InItem.CurSlide.ToString())
						{
							InRichTextBox[i].ForeColor = gf.TextRegionSlideTextColour;
                            InRichTextBox[i].BackColor = gf.TextRegionSlideBackColour;
						}
						else
						{
							InRichTextBox[i].ForeColor = gf.NormalTextColour;
						}
					}
				}
			}
		}
		public static void Control_Enter(Control InControl)
		{
			Color backColor = InControl.BackColor;
			gf.SetEnterColour(ref backColor);
            InControl.BackColor = backColor;
			if (InControl.Name == "Main_QuickFind")
			{
				((TextBox)InControl).SelectAll();
			}
		}
		public static void Control_Leave(Control InControl)
		{
			Color backColor = InControl.BackColor;
			gf.SetLeaveColour(ref backColor);
			InControl.BackColor = backColor;
		}
		public static void SetEnterColour(ref Color InBackground)
		{
			if (gf.UseFocusedTextRegionColour)
			{
				InBackground = gf.FocusedTextRegionColour;
			}
			else
			{
				InBackground = gf.NormalTextRegionBackColour;
			}
		}
		public static void SetLeaveColour(ref Color InBackground)
		{
			if (InBackground != gf.NormalTextRegionBackColour)
			{
				InBackground = gf.NormalTextRegionBackColour;
			}
		}
		public static string ExtractDocTextContents(string InFileName)
		{
			string result = "";
			if (File.Exists(InFileName))
			{
				string text = Path.GetExtension(InFileName).ToLower();
				if (text != null)
				{
					if (!(text == ".doc"))
					{
						if (text == ".txt")
						{
							result = gf.LoadTextFile(InFileName);
						}
					}
					else
					{
						result = gf.GetOfficeDocContents(InFileName);
					}
				}
			}
			return result;
		}
		public static void LoadIndividualFormatData(ref gf.SongSettings InItem, string InFormatString)
		{
			for (int i = 0; i < 255; i++)
			{
				InItem.Format.HeaderData[i] = gf.ExtractHeaderInfo(InFormatString, i, '>');
			}
			int folderNo = InItem.FolderNo;
			int num = folderNo;
			int num2 = 1;
			if (InItem.Type == "B")
			{
				num = InItem.HBR2_FolderNo;
				num2 = 0;
			}
			if (folderNo >= 0)
			{
				InItem.FolderNo = folderNo;
				gf.ShowFontBold[0, 0] = gf.ShowFontBold[folderNo, 0];
				gf.ShowFontBold[0, 1] = gf.ShowFontBold[num, num2];
				gf.ShowFontItalic[0, 0] = gf.ShowFontItalic[folderNo, 0];
				gf.ShowFontItalic[0, 1] = gf.ShowFontItalic[num, num2];
				gf.ShowFontUnderline[0, 0] = gf.ShowFontUnderline[folderNo, 0];
				gf.ShowFontUnderline[0, 1] = gf.ShowFontUnderline[num, num2];
				gf.ShowFontRTL[0, 0] = gf.ShowFontRTL[folderNo, 0];
				gf.ShowFontRTL[0, 1] = gf.ShowFontRTL[num, num2];
				gf.ShowFontBold[0, 2] = gf.ShowFontBold[folderNo, 0];
				gf.ShowFontBold[0, 3] = gf.ShowFontBold[num, num2];
				gf.ShowFontItalic[0, 2] = gf.ShowFontItalic[folderNo, 2];
				gf.ShowFontItalic[0, 3] = gf.ShowFontItalic[num, 3];
				gf.ShowFontUnderline[0, 2] = gf.ShowFontUnderline[folderNo, 0];
				gf.ShowFontUnderline[0, 3] = gf.ShowFontUnderline[num, num2];
				gf.ShowFontName[0, 0] = gf.ShowFontName[folderNo, 0];
				gf.ShowFontName[0, 1] = gf.ShowFontName[num, num2];
				gf.ShowFontSize[0, 0] = gf.ShowFontSize[folderNo, 0] * InItem.FontSizeFactor / 100;
				gf.ShowFontSize[0, 1] = gf.ShowFontSize[num, num2] * ((InItem.Type == "B") ? InItem.HBR2_FontSizeFactor : InItem.FontSizeFactor) / 100;
				if (gf.ShowFontSize[0, 0] <= 0)
				{
					gf.ShowFontSize[0, 0] = 6;
				}
				if (gf.ShowFontSize[0, 1] <= 0)
				{
					gf.ShowFontSize[0, 1] = 6;
				}
				gf.ShowBottomMargin[0] = gf.ShowBottomMargin[folderNo];
				gf.ShowLeftMargin[0] = gf.ShowLeftMargin[folderNo];
				gf.ShowRightMargin[0] = gf.ShowRightMargin[folderNo];
				gf.ShowFontVPosition[0, 0] = gf.ShowFontVPosition[folderNo, 0];
				gf.ShowFontVPosition[0, 1] = gf.ShowFontVPosition[folderNo, 1];
				gf.FolderHeadingFontBold[0, 0] = gf.FolderHeadingFontBold[folderNo, 0];
				gf.FolderHeadingFontItalic[0, 0] = gf.FolderHeadingFontItalic[folderNo, 0];
				gf.FolderHeadingFontUnderline[0, 0] = gf.FolderHeadingFontUnderline[folderNo, 0];
				gf.FolderHeadingFontBold[0, 1] = gf.FolderHeadingFontBold[folderNo, 1];
				gf.FolderHeadingFontItalic[0, 1] = gf.FolderHeadingFontItalic[folderNo, 1];
				gf.FolderHeadingFontUnderline[0, 1] = gf.FolderHeadingFontUnderline[folderNo, 1];
				gf.FolderHeadingPercentSize[0] = gf.FolderHeadingPercentSize[folderNo];
				gf.FolderHeadingOption[0] = gf.FolderHeadingOption[folderNo];
				gf.ShowLineSpacing[0, 0] = gf.ShowLineSpacing[folderNo, 0];
				gf.ShowLineSpacing[0, 1] = gf.ShowLineSpacing[folderNo, 1];
			}
			int num3 = gf.ExtractNumericData(InItem.Format.HeaderData[21]);
			InItem.Format.ShowSongHeadings = ((num3 < 0 | num3 > 3) ? gf.ShowSongHeadings : num3);
			num3 = gf.ExtractNumericData(InItem.Format.HeaderData[22]);
			InItem.Format.UseShadowFont = ((num3 < 0) ? gf.UseShadowFont : gf.GetBitValue(num3, 2));
			InItem.Format.ShowNotations = ((num3 < 0) ? gf.ShowNotations : gf.GetBitValue(num3, 3));
			InItem.Format.ShowInterlace = ((num3 < 0) ? gf.ShowInterlace : gf.GetBitValue(num3, 5));
			InItem.Format.UseOutlineFont = ((num3 < 0) ? gf.UseOutlineFont : gf.GetBitValue(num3, 6));
			InItem.Format.HideDisplayPanel = ((num3 < 0) ? 0 : gf.GetBitValue(num3, 7));
			num3 = gf.ExtractNumericData(InItem.Format.HeaderData[23]);
			InItem.Format.ShowSongHeadingsAlign = ((num3 < 0 | num3 > 4) ? gf.ShowSongHeadingsAlign : num3);
			num3 = gf.ExtractNumericData(InItem.Format.HeaderData[25]);
			InItem.Format.ShowLyrics = ((num3 < 0 | num3 > 2) ? gf.ShowLyrics : num3);
			num3 = gf.ExtractNumericData(InItem.Format.HeaderData[26]);
			InItem.Format.ShowScreenColour[0] = ((InItem.Format.HeaderData[26] == "" | !gf.ValidateColour(num3)) ? gf.ShowScreenColour[0] : Color.FromArgb(Convert.ToInt32(num3)));
			num3 = gf.ExtractNumericData(InItem.Format.HeaderData[27]);
			InItem.Format.ShowScreenColour[1] = ((InItem.Format.HeaderData[27] == "" | !gf.ValidateColour(num3)) ? gf.ShowScreenColour[0] : Color.FromArgb(Convert.ToInt32(num3)));
			num3 = gf.ExtractNumericData(InItem.Format.HeaderData[28]);
			InItem.Format.ShowScreenStyle = ((num3 < 0 | num3 > gf.MaxBackgroundStyleIndex) ? gf.ShowScreenStyle : num3);
			num3 = gf.ExtractNumericData(InItem.Format.HeaderData[29]);
			InItem.Format.ShowFontColour[0] = ((InItem.Format.HeaderData[29] == "" | !gf.ValidateColour(num3)) ? gf.ShowFontColour[0] : Color.FromArgb(Convert.ToInt32(num3)));
			num3 = gf.ExtractNumericData(InItem.Format.HeaderData[30]);
			InItem.Format.ShowFontColour[1] = ((InItem.Format.HeaderData[30] == "" | !gf.ValidateColour(num3)) ? gf.ShowFontColour[1] : Color.FromArgb(Convert.ToInt32(num3)));
			num3 = gf.ExtractNumericData(InItem.Format.HeaderData[31]);
			InItem.Format.ShowFontAlign[0] = ((num3 < 1 | num3 > 3) ? gf.ShowFontAlign[0, 0] : num3);
			num3 = gf.ExtractNumericData(InItem.Format.HeaderData[32]);
			InItem.Format.ShowFontAlign[1] = ((num3 < 1 | num3 > 3) ? gf.ShowFontAlign[0, 1] : num3);
			num3 = gf.ExtractNumericData(InItem.Format.HeaderData[41]);
			InItem.Format.ShowFontBold[0] = ((num3 < 0 || num3 > 127) ? gf.ShowFontBold[0, 0] : gf.GetBitValue(num3, 1));
			InItem.Format.ShowFontItalic[0] = ((num3 < 0 || num3 > 127) ? gf.ShowFontItalic[0, 0] : gf.GetBitValue(num3, 2));
			InItem.Format.ShowFontUnderline[0] = ((num3 < 0 || num3 > 127) ? gf.ShowFontUnderline[0, 0] : gf.GetBitValue(num3, 3));
			InItem.Format.ShowFontBold[2] = ((num3 < 0 || num3 > 127) ? gf.ShowFontBold[0, 1] : gf.GetBitValue(num3, 4));
			InItem.Format.ShowFontItalic[2] = ((num3 < 0 || num3 > 127) ? gf.ShowFontItalic[0, 2] : gf.GetBitValue(num3, 5));
			InItem.Format.ShowFontUnderline[2] = ((num3 < 0 || num3 > 127) ? gf.ShowFontUnderline[0, 1] : gf.GetBitValue(num3, 6));
			num3 = gf.ExtractNumericData(InItem.Format.HeaderData[42]);
			InItem.Format.ShowFontBold[1] = ((num3 < 0 || num3 > 127) ? gf.ShowFontBold[0, 1] : gf.GetBitValue(num3, 1));
			InItem.Format.ShowFontItalic[1] = ((num3 < 0 || num3 > 127) ? gf.ShowFontItalic[0, 1] : gf.GetBitValue(num3, 2));
			InItem.Format.ShowFontUnderline[1] = ((num3 < 0 || num3 > 127) ? gf.ShowFontUnderline[0, 1] : gf.GetBitValue(num3, 3));
			InItem.Format.ShowFontBold[3] = ((num3 < 0 || num3 > 127) ? gf.ShowFontBold[0, 3] : gf.GetBitValue(num3, 4));
			InItem.Format.ShowFontItalic[3] = ((num3 < 0 || num3 > 127) ? gf.ShowFontItalic[0, 3] : gf.GetBitValue(num3, 5));
			InItem.Format.ShowFontUnderline[3] = ((num3 < 0 || num3 > 127) ? gf.ShowFontUnderline[0, 3] : gf.GetBitValue(num3, 6));
			InItem.Format.ShowFontName[0] = ((InItem.Format.HeaderData[43] == "") ? gf.ShowFontName[0, 0] : InItem.Format.HeaderData[43]);
			InItem.Format.ShowFontName[1] = ((InItem.Format.HeaderData[44] == "") ? gf.ShowFontName[0, 1] : InItem.Format.HeaderData[44]);
			num3 = gf.ExtractNumericData(InItem.Format.HeaderData[45]);
			InItem.Format.ShowFontVPosition[0] = ((num3 < 0 | num3 > 100) ? gf.ShowFontVPosition[0, 0] : num3);
			num3 = gf.ExtractNumericData(InItem.Format.HeaderData[46]);
			InItem.Format.ShowFontVPosition[1] = ((num3 < InItem.Format.ShowFontVPosition[0] | num3 > 100) ? gf.ShowFontVPosition[0, 1] : num3);
			num3 = gf.ExtractNumericData(InItem.Format.HeaderData[47]);
			InItem.Format.ShowFontSize[0] = ((num3 < 6 | num3 > 100) ? gf.ShowFontSize[0, 0] : num3);
			num3 = gf.ExtractNumericData(InItem.Format.HeaderData[48]);
			InItem.Format.ShowFontSize[1] = ((num3 < 6 | num3 > 100) ? gf.ShowFontSize[0, 1] : num3);
			num3 = gf.ExtractNumericData(InItem.Format.HeaderData[71]);
			InItem.Format.TransposeOffset = ((num3 < 0 | num3 > 11) ? 0 : num3);
			InItem.Format.PreviousTransposeOffset = InItem.Format.TransposeOffset;
			InItem.Format.BackgroundPicture = InItem.Format.HeaderData[61];
			num3 = gf.ExtractNumericData(InItem.Format.HeaderData[50]);
			InItem.Format.MediaOption = ((num3 < 0 | num3 > 3) ? gf.MediaOption : num3);
			InItem.Format.MediaLocation = InItem.Format.HeaderData[51];
			num3 = gf.ExtractNumericData(InItem.Format.HeaderData[52]);
			InItem.Format.MediaVolume = ((num3 < 0 | num3 > 100) ? gf.MediaVolume : num3);
			num3 = gf.ExtractNumericData(InItem.Format.HeaderData[53]);
			InItem.Format.MediaBalance = ((num3 < -100 | num3 > 100) ? gf.MediaBalance : num3);
			num3 = gf.ExtractNumericData(InItem.Format.HeaderData[54]);
			InItem.Format.MediaMute = ((num3 < 0) ? gf.MediaMute : gf.GetBitValue(num3, 1));
			InItem.Format.MediaRepeat = ((num3 < 0) ? gf.MediaRepeat : gf.GetBitValue(num3, 2));
			InItem.Format.MediaWidescreen = ((num3 < 0) ? gf.MediaWidescreen : gf.GetBitValue(num3, 3));
			if (InItem.Type == "M")
			{
				InItem.Format.ShowSongHeadings = 0;
				InItem.Format.MediaOption = 2;
				InItem.Format.MediaLocation = InItem.ItemID;
			}
			num3 = gf.ExtractNumericData(InItem.Format.HeaderData[55]);
			InItem.Format.MediaCaptureDeviceNumber = ((num3 < 1 | num3 > 5) ? 1 : num3);
			num3 = gf.ExtractNumericData(InItem.Format.HeaderData[62]);
			InItem.Format.BackgroundMode = ((num3 < 0 | num3 > 2) ? gf.BackgroundMode : ((gf.ImageMode)num3));
			num3 = gf.ExtractNumericData(InItem.Format.HeaderData[63]);
			InItem.Format.ShowVerticalAlign = ((num3 < 0 | num3 > 2) ? gf.ShowVerticalAlign : num3);
			num3 = gf.ExtractNumericData(InItem.Format.HeaderData[64]);
			InItem.Format.ShowLeftMargin = ((num3 < 0 | num3 > 40) ? gf.ShowLeftMargin[0] : num3);
			num3 = gf.ExtractNumericData(InItem.Format.HeaderData[65]);
			InItem.Format.ShowRightMargin = ((num3 < 0 | num3 > 40) ? gf.ShowRightMargin[0] : num3);
			num3 = gf.ExtractNumericData(InItem.Format.HeaderData[66]);
			InItem.Format.ShowBottomMargin = ((num3 < 0 | num3 > 100) ? gf.ShowBottomMargin[0] : num3);
			if (InItem.Format.HeaderData[72] != "")
			{
				InItem.Format.ShowItemTransition = gf.GlobalImageCanvas.GetTransitionType(InItem.Format.HeaderData[72]);
			}
			else
			{
				InItem.Format.ShowItemTransition = gf.ShowItemTransition;
			}
			if (InItem.Format.HeaderData[73] != "")
			{
				InItem.Format.ShowSlideTransition = gf.GlobalImageCanvas.GetTransitionType(InItem.Format.HeaderData[73]);
			}
			else
			{
				InItem.Format.ShowSlideTransition = gf.ShowSlideTransition;
			}
			InItem.Format.FormatString = InFormatString;
			InItem.UseDefaultFormat = (InFormatString == "");
			if (InItem.Format.ImageString != "" && InItem.Format.BackgroundPicture != "")
			{
				InItem.Format.TempImageFileName = gf.dumpImageToFile(Convert.FromBase64String(InItem.Format.ImageString), InItem.Format.BackgroundPicture);
			}
		}
	}
}
